Skip to content

Commit

Permalink
[FIX] logistics_planning_invoicing
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianSantamaria committed Dec 5, 2024
1 parent d1be0f4 commit 0cd25e7
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 0cd25e7

Please sign in to comment.