diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 0cb9165490e..9b355c1fece 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -109,6 +109,8 @@ + + @@ -194,6 +196,8 @@ + + @@ -286,6 +290,8 @@ + + diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 9127d64cad3..773fa55e44d 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -1471,6 +1471,24 @@ account_invoice_line() class account_invoice_tax(osv.osv): _name = "account.invoice.tax" _description = "Invoice Tax" + + def _count_factor(self, cr, uid, ids, name, args, context=None): + res = {} + for invoice_tax in self.browse(cr, uid, ids, context=context): + res[invoice_tax.id] = { + 'factor_base': 1.0, + 'factor_tax': 1.0, + } + if invoice_tax.amount <> 0.0: + factor_tax = invoice_tax.tax_amount / invoice_tax.amount + res[invoice_tax.id]['factor_tax'] = factor_tax + + if invoice_tax.base <> 0.0: + factor_base = invoice_tax.base_amount / invoice_tax.base + res[invoice_tax.id]['factor_base'] = factor_base + + return res + _columns = { 'invoice_id': fields.many2one('account.invoice', 'Invoice Line', ondelete='cascade', select=True), 'name': fields.char('Tax Description', size=64, required=True), @@ -1485,33 +1503,34 @@ class account_invoice_tax(osv.osv): 'tax_code_id': fields.many2one('account.tax.code', 'Tax Code', help="The tax basis of the tax declaration."), 'tax_amount': fields.float('Tax Code Amount', digits_compute=dp.get_precision('Account')), 'company_id': fields.related('account_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True), + 'factor_base' : fields.function(_count_factor, method=True, string='Multipication factor for Base code', type='float', multi="all"), + 'factor_tax' : fields.function(_count_factor, method=True, string='Multipication factor Tax code', type='float', multi="all") } def base_change(self, cr, uid, ids, base, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency = False + factor = 1 + if ids: + factor = self.read(cr, uid, ids[0], ['factor_base'])['factor_base'] if company_id: company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: - base = cur_obj.compute(cr, uid, currency_id, company_currency, base, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) + base = cur_obj.compute(cr, uid, currency_id, company_currency, base*factor, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'base_amount':base}} def amount_change(self, cr, uid, ids, amount, currency_id=False, company_id=False, date_invoice=False): cur_obj = self.pool.get('res.currency') company_obj = self.pool.get('res.company') company_currency = False - tax_sign = 1 + factor = 1 if ids: - tax_amount = self.read(cr, uid, ids[0], ['tax_amount'])['tax_amount'] - if tax_amount < 0: - tax_sign = -1 - elif tax_amount == 0: - tax_sign = 0 + factor = self.read(cr, uid, ids[0], ['factor_tax'])['factor_tax'] if company_id: company_currency = company_obj.read(cr, uid, [company_id], ['currency_id'])[0]['currency_id'][0] if currency_id and company_currency: - amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*tax_sign, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) + amount = cur_obj.compute(cr, uid, currency_id, company_currency, amount*factor, context={'date': date_invoice or time.strftime('%Y-%m-%d')}, round=False) return {'value': {'tax_amount': amount}} _order = 'sequence' diff --git a/addons/account_invoice_layout/account_invoice_layout_report.xml b/addons/account_invoice_layout/account_invoice_layout_report.xml index 4b21fcd5b33..ba7f44f0661 100644 --- a/addons/account_invoice_layout/account_invoice_layout_report.xml +++ b/addons/account_invoice_layout/account_invoice_layout_report.xml @@ -8,5 +8,14 @@ name="account.invoice.layout" rml="account_invoice_layout/report/report_account_invoice_layout.rml" auto="False"/> + + + diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 5d5fb5d3114..d4b08ad2b44 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -119,7 +119,7 @@ class crm_lead(crm_case, osv.osv): 'write_date': fields.datetime('Update Date' , readonly=True), # Lead fields - 'categ_id': fields.many2one('crm.case.categ', 'Lead Source', \ + 'categ_id': fields.many2one('crm.case.categ', 'Category', \ domain="[('section_id','=',section_id),\ ('object_id.model', '=', 'crm.lead')]"), 'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', \ @@ -148,7 +148,7 @@ class crm_lead(crm_case, osv.osv): \nIf the case is in progress the state is set to \'Open\'.\ \nWhen the case is over, the state is set to \'Done\'.\ \nIf the case needs to be reviewed then the state is set to \'Pending\'.'), - 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)], readonly=True), + 'message_ids': fields.one2many('mailgate.message', 'res_id', 'Messages', domain=[('model','=',_name)]), 'partner_assigned_id': fields.many2one('res.partner', 'Assigned Partner', help="Partner this case has been forwarded/assigned to.", select=True), 'date_assign': fields.date('Assignation Date', help="Last date this case was forwarded/assigned to a partner"), } diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index b70174e8989..9517edc5f3a 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -57,6 +57,9 @@ +