From 58024d6e0849400bb9c86f7c7988b163958eebe0 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 28 Feb 2024 14:56:34 +0700 Subject: delivery invoice address on so and invoices --- indoteknik_custom/models/account_move.py | 12 ++++++++++++ indoteknik_custom/models/sale_advance_payment_inv.py | 1 + indoteknik_custom/models/sale_order.py | 7 +++++++ indoteknik_custom/views/account_move.xml | 4 ++++ indoteknik_custom/views/sale_order.xml | 1 + 5 files changed, 25 insertions(+) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 7eb65e9f..b505850f 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -39,6 +39,18 @@ class AccountMove(models.Model): reklas_id = fields.Many2one('account.move', string='Nomor CAB', domain="[('partner_id', '=', partner_id)]") new_invoice_day_to_due = fields.Integer(string="New Day Due", compute="_compute_invoice_day_to_due") date_efaktur_upload = fields.Datetime(string='eFaktur Upload Date', tracking=True) + real_invoice_id = fields.Many2one( + 'res.partner', string='Delivery Invoice Address', readonly=True, required=True, + states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]}, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", + help="Dipakai untuk alamat tempel") + + address_invoice = fields.Char(related='real_invoice_id.street', string='Invoice Address', readonly=True) + + @api.constrains('partner_id') + def _constrains_real_invoice(self): + for move in self: + move.real_invoice_id = move.sale_id.real_invoice_id @api.constrains('efaktur_document') def _constrains_date_efaktur(self): diff --git a/indoteknik_custom/models/sale_advance_payment_inv.py b/indoteknik_custom/models/sale_advance_payment_inv.py index ebbba6b9..bea9a900 100644 --- a/indoteknik_custom/models/sale_advance_payment_inv.py +++ b/indoteknik_custom/models/sale_advance_payment_inv.py @@ -19,6 +19,7 @@ class SaleAdvancePaymentInv(models.TransientModel): 'sale_id': order.id, 'fiscal_position_id': (order.fiscal_position_id or order.fiscal_position_id.get_fiscal_position(order.partner_id.id)).id, 'partner_shipping_id': parent_id.id, + 'real_invoice_id': order.real_invoice_id.id, 'currency_id': order.pricelist_id.currency_id.id, 'payment_reference': order.reference, 'invoice_payment_term_id': order.payment_term_id.id, diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py index 4176a464..f44f624e 100755 --- a/indoteknik_custom/models/sale_order.py +++ b/indoteknik_custom/models/sale_order.py @@ -36,6 +36,11 @@ class SaleOrder(models.Model): states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]}, domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", help="Dipakai untuk alamat tempel") + real_invoice_id = fields.Many2one( + 'res.partner', string='Delivery Invoice Address', readonly=True, required=True, + states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]}, + domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]", + help="Dipakai untuk alamat tempel") fee_third_party = fields.Float('Fee Pihak Ketiga') so_status = fields.Selection([ ('terproses', 'Terproses'), @@ -126,6 +131,7 @@ class SaleOrder(models.Model): 'team_id': self.team_id.id, 'partner_id': parent_id.id, 'partner_shipping_id': parent_id.id, + 'real_invoice_id': self.real_invoice_id.id, 'fiscal_position_id': (self.fiscal_position_id or self.fiscal_position_id.get_fiscal_position(self.partner_invoice_id.id)).id, 'partner_bank_id': self.company_id.partner_id.bank_ids[:1].id, 'journal_id': journal.id, # company comes from the journal @@ -312,6 +318,7 @@ class SaleOrder(models.Model): @api.onchange('partner_shipping_id') def onchange_partner_shipping(self): self.real_shipping_id = self.partner_shipping_id + self.real_invoice_id = self.partner_invoice_id @api.onchange('partner_id') def onchange_partner_contact(self): diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 97951b95..cf03809b 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -23,6 +23,10 @@ + + + + diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml index 2f800e34..64e6ad7b 100755 --- a/indoteknik_custom/views/sale_order.xml +++ b/indoteknik_custom/views/sale_order.xml @@ -61,6 +61,7 @@ + -- cgit v1.2.3