diff --git a/addons/account/account.py b/addons/account/account.py index c1a30967aea..2c954b9ee57 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1963,8 +1963,8 @@ class account_tax(osv.osv): return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] _defaults = { - 'python_compute': '''# price_unit\n# address: res.partner.address object or False\n# product: product.product object or None\n# partner: res.partner object or None\n\nresult = price_unit * 0.10''', - 'python_compute_inv': '''# price_unit\n# address: res.partner.address object or False\n# product: product.product object or False\n\nresult = price_unit * 0.10''', + 'python_compute': '''# price_unit\n# address: res.partner object or False\n# product: product.product object or None\n# partner: res.partner object or None\n\nresult = price_unit * 0.10''', + 'python_compute_inv': '''# price_unit\n# address: res.partner object or False\n# product: product.product object or False\n\nresult = price_unit * 0.10''', 'applicable_type': 'true', 'type': 'percent', 'amount': 0, @@ -1983,7 +1983,7 @@ class account_tax(osv.osv): def _applicable(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None): res = [] - obj_partener_address = self.pool.get('res.partner.address') + obj_partener_address = self.pool.get('res.partner') for tax in taxes: if tax.applicable_type=='code': localdict = {'price_unit':price_unit, 'address':obj_partener_address.browse(cr, uid, address_id), 'product':product, 'partner':partner} @@ -1998,7 +1998,7 @@ class account_tax(osv.osv): taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner) res = [] cur_price_unit=price_unit - obj_partener_address = self.pool.get('res.partner.address') + obj_partener_address = self.pool.get('res.partner') for tax in taxes: # we compute the amount for the current tax object and append it to the result data = {'id':tax.id, @@ -2125,7 +2125,7 @@ class account_tax(osv.osv): def _unit_compute_inv(self, cr, uid, taxes, price_unit, address_id=None, product=None, partner=None): taxes = self._applicable(cr, uid, taxes, price_unit, address_id, product, partner) - obj_partener_address = self.pool.get('res.partner.address') + obj_partener_address = self.pool.get('res.partner') res = [] taxes.reverse() cur_price_unit = price_unit @@ -2806,8 +2806,8 @@ class account_tax_template(osv.osv): return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0] _defaults = { - 'python_compute': lambda *a: '''# price_unit\n# address: res.partner.address object or False\n# product: product.product object or None\n# partner: res.partner object or None\n\nresult = price_unit * 0.10''', - 'python_compute_inv': lambda *a: '''# price_unit\n# address: res.partner.address object or False\n# product: product.product object or False\n\nresult = price_unit * 0.10''', + 'python_compute': lambda *a: '''# price_unit\n# address: res.partner object or False\n# product: product.product object or None\n# partner: res.partner object or None\n\nresult = price_unit * 0.10''', + 'python_compute_inv': lambda *a: '''# price_unit\n# address: res.partner object or False\n# product: product.product object or False\n\nresult = price_unit * 0.10''', 'applicable_type': 'true', 'type': 'percent', 'amount': 0, diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index 5e5ac5f482b..5b51ba9b96b 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -216,8 +216,7 @@ class account_invoice(osv.osv): help="If you use payment terms, the due date will be computed automatically at the generation "\ "of accounting entries. If you keep the payment term and the due date empty, it means direct payment. The payment term may compute several due dates, for example 50% now, 50% in one month."), 'partner_id': fields.many2one('res.partner', 'Partner', change_default=True, readonly=True, required=True, states={'draft':[('readonly',False)]}), - 'address_contact_id': fields.many2one('res.partner.address', 'Contact Address', readonly=True, states={'draft':[('readonly',False)]}), - 'address_invoice_id': fields.many2one('res.partner.address', 'Invoice Address', readonly=True, required=True, states={'draft':[('readonly',False)]}), + 'address_contact_id': fields.many2one('res.partner', 'Contact Address', readonly=True, states={'draft':[('readonly',False)]}), 'payment_term': fields.many2one('account.payment.term', 'Payment Term',readonly=True, states={'draft':[('readonly',False)]}, help="If you use payment terms, the due date will be computed automatically at the generation "\ "of accounting entries. If you keep the payment term and the due date empty, it means direct payment. "\ @@ -443,7 +442,6 @@ class account_invoice(osv.osv): result = {'value': { 'address_contact_id': contact_addr_id, - 'address_invoice_id': invoice_addr_id, 'account_id': acc_id, 'payment_term': partner_payment_term, 'fiscal_position': fiscal_position @@ -1092,7 +1090,7 @@ class account_invoice(osv.osv): return map(lambda x: (0,0,x), lines) def refund(self, cr, uid, ids, date=None, period_id=None, description=None, journal_id=None): - invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'address_contact_id', 'address_invoice_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id']) + invoices = self.read(cr, uid, ids, ['name', 'type', 'number', 'reference', 'comment', 'date_due', 'partner_id', 'address_contact_id', 'partner_contact', 'partner_insite', 'partner_ref', 'payment_term', 'account_id', 'currency_id', 'invoice_line', 'tax_line', 'journal_id']) obj_invoice_line = self.pool.get('account.invoice.line') obj_invoice_tax = self.pool.get('account.invoice.tax') obj_journal = self.pool.get('account.journal') @@ -1140,7 +1138,7 @@ class account_invoice(osv.osv): 'name': description, }) # take the id part of the tuple returned for many2one fields - for field in ('address_contact_id', 'address_invoice_id', 'partner_id', + for field in ('address_contact_id', 'partner_id', 'account_id', 'currency_id', 'payment_term', 'journal_id'): invoice[field] = invoice[field] and invoice[field][0] # create the new invoice @@ -1257,7 +1255,7 @@ class account_invoice_line(osv.osv): cur_obj = self.pool.get('res.currency') for line in self.browse(cr, uid, ids): price = line.price_unit * (1-(line.discount or 0.0)/100.0) - taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, product=line.product_id, address_id=line.invoice_id.address_invoice_id, partner=line.invoice_id.partner_id) + taxes = tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, price, line.quantity, product=line.product_id, partner=line.invoice_id.partner_id) res[line.id] = taxes['total'] if line.invoice_id: cur = line.invoice_id.currency_id @@ -1277,7 +1275,7 @@ class account_invoice_line(osv.osv): taxes = l[2].get('invoice_line_tax_id') if len(taxes[0]) >= 3 and taxes[0][2]: taxes = tax_obj.browse(cr, uid, list(taxes[0][2])) - for tax in tax_obj.compute_all(cr, uid, taxes, p,l[2].get('quantity'), context.get('address_invoice_id', False), l[2].get('product_id', False), context.get('partner_id', False))['taxes']: + for tax in tax_obj.compute_all(cr, uid, taxes, p,l[2].get('quantity'), l[2].get('product_id', False), context.get('partner_id', False))['taxes']: t = t - tax['amount'] return t return 0 @@ -1322,7 +1320,7 @@ class account_invoice_line(osv.osv): res['arch'] = etree.tostring(doc) return res - def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None, company_id=None): + def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, currency_id=False, context=None, company_id=None): if context is None: context = {} company_id = company_id if company_id != None else context.get('company_id',False) @@ -1404,7 +1402,7 @@ class account_invoice_line(osv.osv): context = dict(context) context.update({'company_id': company_id}) warning = {} - res = self.product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context=context) + res = self.product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, currency_id, context=context) if 'uos_id' in res['value']: del res['value']['uos_id'] if not uom: @@ -1437,7 +1435,7 @@ class account_invoice_line(osv.osv): tax_code_found= False for tax in tax_obj.compute_all(cr, uid, line.invoice_line_tax_id, (line.price_unit * (1.0 - (line['discount'] or 0.0) / 100.0)), - line.quantity, inv.address_invoice_id.id, line.product_id, + line.quantity, inv.address_contact_id.id, line.product_id, inv.partner_id)['taxes']: if inv.type in ('out_invoice', 'in_invoice'): @@ -1572,7 +1570,7 @@ class account_invoice_tax(osv.osv): company_currency = inv.company_id.currency_id.id 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']: + 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_contact_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 diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 59977c252f9..80c4901286f 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -51,12 +51,12 @@ form
- +