summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fixco_custom/models/account_move_line.py39
-rwxr-xr-xfixco_custom/models/product_product.py2
-rw-r--r--fixco_custom/views/account_move_line.xml12
3 files changed, 52 insertions, 1 deletions
diff --git a/fixco_custom/models/account_move_line.py b/fixco_custom/models/account_move_line.py
index 2aaf6d9..d192338 100644
--- a/fixco_custom/models/account_move_line.py
+++ b/fixco_custom/models/account_move_line.py
@@ -7,6 +7,45 @@ class AccountMoveLine(models.Model):
qty_outstanding = fields.Float(string='Qty Outstanding', compute='_compute_qty_outstanding')
invoice_marketplace = fields.Text("Invoice Mearketplace", compute='_compute_invoice_marketplace')
+ def action_gl_reconcile(self):
+ lines = self
+
+ # 1️⃣ Create header bank statement
+ account_bank_statement = self.env['account.bank.statement'].create({
+ 'journal_id': 25, # pastiin ini journal bank
+ 'name': 'REKONSIL KAS IN {}'.format(fields.Datetime.now()),
+ 'company_id': 4,
+ 'date': fields.Date.today(),
+ })
+
+ # 2️⃣ Create statement lines dari GL
+ statement_lines_vals = []
+
+ for line in lines:
+ # amount logic:
+ # debit = uang masuk
+ # credit = uang keluar
+ amount = line.debit - line.credit
+
+ statement_lines_vals.append({
+ 'statement_id': account_bank_statement.id,
+ 'date': line.date or fields.Date.today(),
+ 'payment_ref': line.name,
+ 'partner_id': line.partner_id.id if line.partner_id else False,
+ 'amount': amount,
+ 'ref': line.move_id.name,
+ })
+
+ self.env['account.bank.statement.line'].create(statement_lines_vals)
+
+ return {
+ 'effect': {
+ 'fadeout': 'slow',
+ 'message': 'Statement + lines berhasil dibuat! Tinggal reconcile 😎🔥',
+ 'type': 'rainbow_man',
+ }
+ }
+
@api.depends(
'move_id',
'move_id.line_ids.matched_debit_ids',
diff --git a/fixco_custom/models/product_product.py b/fixco_custom/models/product_product.py
index 219d3e1..c9b4d32 100755
--- a/fixco_custom/models/product_product.py
+++ b/fixco_custom/models/product_product.py
@@ -20,7 +20,7 @@ class ProductProduct(models.Model):
# qty_multiple = fields.Float('Minimum Beli')
brand_id = fields.Many2one('brands', string='Brand', required=True)
product_public_category_id = fields.Many2one('product.public.category', string='Public Categories')
- categ_id = fields.Many2one('product.category', string='Category', required=True, default=lambda self: self.env['product.category'].browse(10))
+ categ_id = fields.Many2one('product.category', string='Category', required=True, default=10)
# brand_id = fields.Many2one(required=True)
default_code = fields.Char(required=True)
taxed_id = fields.Many2many('taxes', string='Taxes', required=True)
diff --git a/fixco_custom/views/account_move_line.xml b/fixco_custom/views/account_move_line.xml
index ee4eaa9..245bdfe 100644
--- a/fixco_custom/views/account_move_line.xml
+++ b/fixco_custom/views/account_move_line.xml
@@ -12,4 +12,16 @@
</field>
</record>
</data>
+ <data>
+<record id="action_gl_reconcile_server" model="ir.actions.server">
+ <field name="name">Reconcile Selected</field>
+ <field name="model_id" ref="account.model_account_move_line"/>
+ <field name="binding_model_id" ref="account.model_account_move_line"/>
+ <field name="binding_view_types">list</field>
+ <field name="state">code</field>
+ <field name="code">
+ action = records.action_gl_reconcile()
+ </field>
+ </record>
+</data>
</odoo>