Hi all,
I'm working on building a simple module ('contract') for periodically
creating invoices (like the subscription module discussed earlier).
Everything is working beautifully now, except that I notice no taxes are
added to the invoice lines, even though they are defined correctly on
the product's categories, and 'use category taxes' are set to 'true'.
I'm guessing this has to do with the on_change machinery, but I unsure
how to proceed.
I'm currently using code along these lines:
## create a new invoice
invoice = invoice_obj.create(dict(
company=contract.company.id,
type='out_invoice',
reference=contract.product.code or contract.product.name,
description=contract.description or contract.name,
state='draft',
currency=contract.company.currency.id,
journal=contract.journal.id,
account=contract.party.account_receivable.id,
payment_term=contract.payment_term.id or \
contract.party.payment_term.id,
party=contract.party.id,
invoice_address=invoice_addr.id
))
## create invoice line
account = contract.account or \
contract.product.account_revenue or \
contract.product.category.account_revenue
line = line_obj.create(dict(
type='line',
product=contract.product.id,
invoice=invoice,
description="%s (%s) %s - %s" % \
(contract.product.description or
contract.product.name,
contract.name,
last_date, next_date),
quantity=Decimal("%f" % \
(contract.interval_quant * contract.quantity)),
account=account.id,
unit=contract.product.default_uom.id,
unit_price=contract.product.list_price,
contract=contract.id,
))
Do I need to really need to iterate over all fields of the invoice and
invoiceline models to determine the on_change(_with) fields, and call
those manually? If so, is there a specific reason this kind of
functionality isn't part of the framework proper? Or are there helper
functions that support this?
I know from working with proteus that currently the client needs to call
the on_change code, but is that also required for modules?
--
________________________________________________________________
Paul Stevens paul at nfg.nl
NET FACILITIES GROUP GPG/PGP: 1024D/11F8CD31
The Netherlands________________________________http://www.nfg.nl
--
[email protected] mailing list