Rifakat (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.1-opw-579990-rha into
lp:openobject-addons/6.1.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
Related bugs:
Bug #1060856 in OpenERP Addons: "[6.1] cumulation of account & product
default taxes on invoice lines"
https://bugs.launchpad.net/openobject-addons/+bug/1060856
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-579990-rha/+merge/128241
Hello,
Default taxes from product and taxes from the Account are filled in the invoice
line taxes
while we select any product. Only product default taxes should be filled into
invoice line,
account taxes should be considered when there is no product.
lp:1060856 shows detail information.
A backport from the trunk r7668, Revision ID:
[email protected]
This fix has some code refactoring too.
Regards,
Rifakat Haradwala
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-579990-rha/+merge/128241
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.1-opw-579990-rha.
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py 2012-08-20 15:52:57 +0000
+++ account/account_invoice.py 2012-10-05 12:56:37 +0000
@@ -1493,16 +1493,19 @@
def onchange_account_id(self, cr, uid, ids, product_id, partner_id, inv_type, fposition_id, account_id):
if not account_id:
return {}
- taxes = self.pool.get('account.account').browse(cr, uid, account_id).tax_ids
+ unique_tax_ids = []
fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id) or False
- tax_ids = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
-
- product_change_result = self.product_id_change(cr, uid, ids, product_id, False, type=inv_type,
- partner_id=partner_id, fposition_id=fposition_id)
- unique_tax_ids = set(tax_ids)
- if product_change_result and 'value' in product_change_result and 'invoice_line_tax_id' in product_change_result['value']:
- unique_tax_ids |= set(product_change_result['value']['invoice_line_tax_id'])
- return {'value':{'invoice_line_tax_id': list(unique_tax_ids)}}
+ account = self.pool.get('account.account').browse(cr, uid, account_id)
+ if not product_id:
+ taxes = account.tax_ids
+ unique_tax_ids = self.pool.get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
+ else:
+ product_change_result = self.product_id_change(cr, uid, ids, product_id, False, type=inv_type,
+ partner_id=partner_id, fposition_id=fposition_id,
+ company_id=account.company_id.id)
+ if product_change_result and 'value' in product_change_result and 'invoice_line_tax_id' in product_change_result['value']:
+ unique_tax_ids = product_change_result['value']['invoice_line_tax_id']
+ return {'value':{'invoice_line_tax_id': unique_tax_ids}}
account_invoice_line()
@@ -1586,14 +1589,13 @@
for line in inv.invoice_line:
for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, (line.price_unit* (1-(line.discount or 0.0)/100.0)), line.quantity, inv.address_invoice_id.id, line.product_id, inv.partner_id)['taxes']:
- tax['price_unit'] = cur_obj.round(cr, uid, cur, tax['price_unit'])
val={}
val['invoice_id'] = inv.id
val['name'] = tax['name']
val['amount'] = tax['amount']
val['manual'] = False
val['sequence'] = tax['sequence']
- val['base'] = tax['price_unit'] * line['quantity']
+ val['base'] = cur_obj.round(cr, uid, cur, tax['price_unit'] * line['quantity'])
if inv.type in ('out_invoice','in_invoice'):
val['base_code_id'] = tax['base_code_id']
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp