Hello all,
There's something I can't figure out, any help is appreciated. I think I don't understand the new concept 'environment' (env) in the V8 api very well.
Check_total allows to check for mismatches between computed total and invoice total in a purchase account.
Situation : While entering the purchase invoice, I would like to have the remaining amount automaticaly filled when inserting a new invoice_line, sort of inverse running total.
Browsing the code, I stumble upon :
account_invoice.py - class account_invoice_line:
@api.model
def _default_price_unit(self):
if not self._context.get('check_total'):
return 0
total = self._context['check_total']
for l in self._context.get('invoice_line', []):
However, the context variables 'check_total' and 'invoice_line' don't seem to exist. Therefore, _default_price_unit is always returns 0 (zero) instead of check_total minus running total.
Other behaviour I noticed:
- I changed the account_invoice view as so the check_total value is passed to the invoice_line one2many control. The on_change methods on 'product' and 'uom' immediately overwrite the price_unit with 0, as for a new line the product isn't defined yet.
- The VAT isn't calculated in the totals immediately, only when 'apply' is clicked. The code however hints towards other behaviour, see account_invoice.py class account_invoice, function _compute_amount
I have a fix for 1 and 2 (both wip), but I'm unable to retrieve or set the context 'invoice_line' (with_context, ...). I'm also unable to retrieve the current invoice lines when creating a new one (recordset is empty due to @api.model decorator, but removing this doesn't help : there's no link (yet?) with the (although existing, with dbase id) invoice).
What am I missing here?
Kind regards,
Ruben De Baets