+
diff --git a/business_requirement_deliverable_cost/models/business.py b/business_requirement_deliverable_cost/models/business.py
index e534daeeaa..b6dab9f404 100644
--- a/business_requirement_deliverable_cost/models/business.py
+++ b/business_requirement_deliverable_cost/models/business.py
@@ -38,15 +38,15 @@ def _compute_sale_price_total(self):
def product_id_change(self):
super(BusinessRequirementResource, self).product_id_change()
for resource in self:
- deliverable_project = \
+ br = resource.business_requirement_deliverable_id.\
+ business_requirement_id
+ br_project = \
resource.business_requirement_deliverable_id.project_id
- if deliverable_project.pricelist_id and \
- deliverable_project.partner_id and resource.uom_id:
+ pricelist = br.get_estimation_pricelist(br_project)
+ if pricelist and resource.uom_id:
product = resource.product_id.with_context(
- lang=deliverable_project.partner_id.lang,
- partner=deliverable_project.partner_id.id,
quantity=resource.qty,
- pricelist=deliverable_project.pricelist_id.id,
+ pricelist=pricelist.id,
uom=resource.uom_id.id,
)
resource.sale_price_unit = product.price
@@ -59,15 +59,18 @@ def product_uom_change(self):
if not resource.uom_id:
resource.sale_price_unit = 0.0
return
- deliverable_project = \
+ br = resource.business_requirement_deliverable_id.\
+ business_requirement_id
+ br_project = \
resource.business_requirement_deliverable_id.project_id
- if deliverable_project.pricelist_id and \
- deliverable_project.partner_id:
+ partner = br.partner_id
+ pricelist = br.get_estimation_pricelist(br_project)
+ if pricelist and partner:
product = resource.product_id.with_context(
- lang=deliverable_project.partner_id.lang,
- partner=deliverable_project.partner_id.id,
+ lang=partner.lang,
+ partner=partner.id,
quantity=resource.qty,
- pricelist=deliverable_project.pricelist_id.id,
+ pricelist=pricelist.id,
uom=resource.uom_id.id,
)
resource.sale_price_unit = product.price
diff --git a/business_requirement_deliverable_default/models/business_requirement_deliverable_default.py b/business_requirement_deliverable_default/models/business_requirement_deliverable_default.py
index 8e733198d7..e913cb5df9 100644
--- a/business_requirement_deliverable_default/models/business_requirement_deliverable_default.py
+++ b/business_requirement_deliverable_default/models/business_requirement_deliverable_default.py
@@ -8,8 +8,24 @@ class BusinessRequirementDeliverable(models.Model):
_inherit = "business.requirement.deliverable"
def _prepare_resource_lines(self):
- rl_data = self.product_id.sudo().resource_lines.copy_data()
- rl_data = [(0, 0, item) for index, item in enumerate(rl_data)]
+ rl_data = []
+ br = self.business_requirement_id
+ partner = br.partner_id
+ pricelist = br.get_estimation_pricelist(br.project_id)
+ res = self.product_id.sudo().resource_lines.copy_data()
+ for index, item in enumerate(res):
+ if pricelist:
+ product_obj = self.env['product.product'].browse(
+ item.get('product_id'))
+ product = product_obj.with_context(
+ lang=partner.lang,
+ partner=partner.id,
+ quantity=item.get('qty'),
+ pricelist=pricelist.id,
+ uom=item.get('uom_id'),
+ )
+ item.update({'sale_price_unit': product.price})
+ rl_data.append((0, 0, item))
return rl_data
@api.multi