From 901ab091308ec3d575014a7c0540a0cf544702b7 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Tue, 23 Apr 2024 15:04:57 +0700 Subject: add new ir_sequence for account move --- indoteknik_custom/models/account_move.py | 27 +++++++++++++++++++++++++++ indoteknik_custom/views/account_move.xml | 4 ++++ indoteknik_custom/views/ir_sequence.xml | 11 ++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 94a1ab19..22b637e9 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -57,6 +57,33 @@ class AccountMove(models.Model): is_efaktur_uploaded = fields.Boolean(string="Is eFaktur Uploaded", default=False) already_paid = fields.Boolean(string="Sudah Dibayar?", default=False) delivery_amt_text = fields.Char(string="Delivery Amt Terbilang", compute='compute_delivery_amt_text') + so_shipping_paid_by = fields.Char(string="SO Shipping Paid By", compute='compute_so_shipping_paid_by') + so_shipping_covered_by = fields.Char(string="SO Shipping Covered By", compute='compute_so_shipping_paid_by') + so_delivery_amt = fields.Char(string="SO Delivery Amount", compute='compute_so_shipping_paid_by') + flag_delivery_amt = fields.Boolean(string="Flag Delivery Amount", compute='compute_flag_delivery_amt') + nomor_kwitansi = fields.Char(string="Nomor Kwitansi") + + @api.model + def create(self, vals): + if vals['flag_delivery_amt'] == True: + vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0' + else: + vals['nomor_kwitansi'] = None + result = super(AccountMove, self).create(vals) + return result + + def compute_so_shipping_paid_by(self): + for record in self: + record.so_shipping_paid_by = record.sale_id.shipping_paid_by + record.so_shipping_covered_by = record.sale_id.shipping_cost_covered + record.so_delivery_amt = record.sale_id.delivery_amt + + def compute_flag_delivery_amt(self): + for record in self: + if record.sale_id.delivery_amt > 0: + record.flag_delivery_amt = True + else: + record.flag_delivery_amt = False def compute_delivery_amt_text(self): tb = Terbilang() diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index f505ef9d..606a8b24 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -53,6 +53,10 @@ + + + + diff --git a/indoteknik_custom/views/ir_sequence.xml b/indoteknik_custom/views/ir_sequence.xml index d52f55ca..af07ba38 100644 --- a/indoteknik_custom/views/ir_sequence.xml +++ b/indoteknik_custom/views/ir_sequence.xml @@ -90,6 +90,15 @@ 1 1 - + + + Nomor Kwitansi + nomor.kwitansi + TRUE + KWT/%(year)s/ + 5 + 1 + 1 + \ No newline at end of file -- cgit v1.2.3