Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
34 changes: 19 additions & 15 deletions business_requirement_deliverable/models/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,23 @@ 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
unit_price = product.list_price
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
Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion business_requirement_deliverable/models/project.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
3 changes: 2 additions & 1 deletion business_requirement_deliverable/views/business_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<field name="arch" type="xml">
<xpath expr='//page[@string="Business Requirement"]' position='after'>
<page string="Deliverable Lines">
<field name="deliverable_lines" domain="[('business_requirement_line_id', '='. False)]" context="{'tree_view_ref':'business_requirement_deliverable.view_business_requirement_deliverable_tree', 'form_view_ref': 'business_requirement_deliverable.view_business_requirement_deliverable_form', 'default_project_id': project_id,}"/>
<field name="deliverable_lines" domain="[('business_requirement_line_id', '='. False)]" context="{'tree_view_ref':'business_requirement_deliverable.view_business_requirement_deliverable_tree', 'form_view_ref': 'business_requirement_deliverable.view_business_requirement_deliverable_form', 'default_project_id': project_id}"/>
</page>
</xpath>
</field>
Expand Down Expand Up @@ -70,6 +70,7 @@
<group>
<group>
<field name="project_id" invisible="1"/>
<field name="business_requirement_id" invisible="1"/>
<field name="product_id"/>
<label for="qty"/>
<div>
Expand Down
27 changes: 15 additions & 12 deletions business_requirement_deliverable_cost/models/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down