I'm new to Odoo, and using Odoo 13.
There is a sale module in my company, and one product depends to another. So when we create a new invoice (account.move), we must add new invoice line (account.move.line) of depended product.
My code goes like:
new_line = invoice_line_ids.new({
'move_id': self.id,
'product_id': product_id.id,
'_dependency': True,
'quantity': 1.0,
'sequence': sequence,
})
But there is another problem: my new account move line did not compute in account_move.amount_untaxed and account_move.amount_total. For sometimes passing by, I found this function in model AccountMove for calculating those 2 fields:
@api.depends(
'line_ids.debit',
'line_ids.credit',
'line_ids.currency_id',
'line_ids.amount_currency',
'line_ids.amount_residual',
'line_ids.amount_residual_currency',
'line_ids.payment_id.state')
def _compute_amount(self):
No matter what I did, calling it in my code, it just wouldn't goes as expected. But when I ran debug mode in my ide, anytime a new account.move.line added, it triggered.
May I ask why?
Would it not be better to create a package that includes both products and sell that instead? As Fabien managed to chip in, starting by brute force customisation defeats the holistic approach so try this option or check more advanced modules that do similar.