diff --git a/.DS_Store b/.DS_Store index b857216dcd..dad2236ac6 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/business_requirement_deliverable/models/business.py b/business_requirement_deliverable/models/business.py index 3820da9047..cf005371a4 100644 --- a/business_requirement_deliverable/models/business.py +++ b/business_requirement_deliverable/models/business.py @@ -176,6 +176,9 @@ def product_id_change(self): unit_price = 0 product = self.product_id tax_ids = False + br = self.business_requirement_id + pricelist = br.get_estimation_pricelist(br.project_id) + partner = br.partner_id if product: description = product.name_get()[0][1] uom_id = product.uom_id.id @@ -183,14 +186,13 @@ def product_id_change(self): tax_ids = product.taxes_id if product.description_sale: description += '\n' + product.description_sale - if self.business_requirement_id.project_id.pricelist_id and \ - self.business_requirement_id.partner_id and self.uom_id: + if pricelist and \ + br.partner_id and self.uom_id: product = self.product_id.with_context( - lang=self.business_requirement_id.partner_id.lang, - partner=self.business_requirement_id.partner_id.id, + lang=partner.lang, + partner=partner.id, quantity=self.qty, - pricelist=self.business_requirement_id. - project_id.pricelist_id.id, + pricelist=pricelist.id, uom=self.uom_id.id, ) unit_price = product.price @@ -204,14 +206,15 @@ def product_uom_change(self): if not self.uom_id: self.price_unit = 0.0 return - if self.business_requirement_id.project_id.pricelist_id and \ - self.business_requirement_id.partner_id: + br = self.business_requirement_id + pricelist = br.get_estimation_pricelist(br.project_id) + partner = br.partner_id + if pricelist and br.partner_id: product = self.product_id.with_context( - lang=self.business_requirement_id.partner_id.lang, - partner=self.business_requirement_id.partner_id.id, + lang=partner.lang, + partner=partner.id, quantity=self.qty, - pricelist=self.business_requirement_id. - project_id.pricelist_id.id, + pricelist=pricelist.id, uom=self.uom_id.id, ) self.unit_price = product.price @@ -238,16 +241,17 @@ class BusinessRequirement(models.Model): @api.depends( 'deliverable_lines', 'company_id.currency_id', - 'project_id.pricelist_id.currency_id', + 'project_id', ) def _compute_deliverable_total(self): for br in self: + pricelist = br.get_estimation_pricelist(br.project_id) if br.deliverable_lines: total_revenue_origin = sum( line.price_total for line in br.deliverable_lines) - if br.project_id.pricelist_id.currency_id: + if pricelist: br.total_revenue = \ - br.project_id.pricelist_id.currency_id.compute( + pricelist.currency_id.compute( total_revenue_origin, br.company_id.currency_id) else: br.total_revenue = total_revenue_origin diff --git a/business_requirement_deliverable/models/project.py b/business_requirement_deliverable/models/project.py index 2698316551..4b34917c31 100644 --- a/business_requirement_deliverable/models/project.py +++ b/business_requirement_deliverable/models/project.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # © 2016 Elico Corp (https://www.elico-corp.com). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp import fields, models +from openerp import api, fields, models class Project(models.Model): diff --git a/business_requirement_deliverable/views/business_view.xml b/business_requirement_deliverable/views/business_view.xml index 297a86ba11..4363da13bb 100644 --- a/business_requirement_deliverable/views/business_view.xml +++ b/business_requirement_deliverable/views/business_view.xml @@ -9,7 +9,7 @@ - + @@ -70,6 +70,7 @@ +