From 0cd25e7063e29f3fc1ba8dbd6afec48a13fb40b4 Mon Sep 17 00:00:00 2001 From: Christian Santamaria Date: Thu, 5 Dec 2024 10:08:23 +0100 Subject: [PATCH] [FIX] logistics_planning_invoicing --- ...ogistics_schedule_existing_account_move_wizard.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/logistics_planning_invoicing/wizards/logistics_schedule_existing_account_move_wizard.py b/logistics_planning_invoicing/wizards/logistics_schedule_existing_account_move_wizard.py index a88b7fc..484e53b 100644 --- a/logistics_planning_invoicing/wizards/logistics_schedule_existing_account_move_wizard.py +++ b/logistics_planning_invoicing/wizards/logistics_schedule_existing_account_move_wizard.py @@ -15,12 +15,16 @@ class LogisticsScheduleExistingAccountMove(models.TransientModel): invoice_line_id = fields.Many2one('account.move.line', string="Invoice Line") domain_invoice_line_id = fields.Many2many('account.move.line', compute='_compute_domain_invoice_line_id') + def _prepare_domain_invoice_line_id(self): + product_id = self.logistics_schedule_id._get_invoice_product() + if not product_id: + raise ValidationError(_("It is necessary to configure the default products of the logistics planning")) + return [('move_id.partner_id', '=', self.carrier_id.id), ('product_id', '=', product_id.id)] + def _compute_domain_invoice_line_id(self): for record in self: - product_id = record.logistics_schedule_id._get_invoice_product() - if not product_id: - raise ValidationError(_("It is necessary to configure the default products of the logistics planning")) - record.domain_invoice_line_id = self.env['account.move.line'].search([('move_id.partner_id', '=', record.carrier_id.id), ('product_id', '=', product_id.id)]) + domain = record._prepare_domain_invoice_line_id() + record.domain_invoice_line_id = self.env['account.move.line'].search(domain) def add_invoice(self): self.invoice_line_id.agg_logistics_schedule_ids = [(4, self.logistics_schedule_id.id)]