-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] get resource sale unit price from pricelist when get from default #43
base: business_requirement_deliverable_8.0
Are you sure you want to change the base?
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,21 +176,22 @@ def product_id_change(self): | |
unit_price = 0 | ||
product = self.product_id | ||
tax_ids = False | ||
br = self.business_requirement_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 br.project_id.pricelist_id and \ | ||
br.partner_id and self.uom_id: | ||
pricelist = br.project_id.get_closest_ancestor_pricelist() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move before the |
||
product = self.product_id.with_context( | ||
lang=self.business_requirement_id.partner_id.lang, | ||
partner=self.business_requirement_id.partner_id.id, | ||
lang=br.partner_id.lang, | ||
partner=br.partner_id.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 +205,14 @@ 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 | ||
if br.project_id and br.partner_id: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
pricelist = br.project_id.get_closest_ancestor_pricelist() | ||
product = self.product_id.with_context( | ||
lang=self.business_requirement_id.partner_id.lang, | ||
partner=self.business_requirement_id.partner_id.id, | ||
lang=br.partner_id.lang, | ||
partner=br.partner_id.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 +239,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.project_id.get_closest_ancestor_pricelist() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
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 |
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): | ||
|
@@ -15,3 +15,10 @@ class Project(models.Model): | |
Deliverables linked to this project. | ||
Currency of the Deliverables will be the one from this pricelist.''' | ||
) | ||
|
||
@api.multi | ||
def get_closest_ancestor_pricelist(self): | ||
for project in self: | ||
pricelist = self.env['product.pricelist'].browse( | ||
project.pricelist_id.id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure this is enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @elicoidal Seb told me that the rule had not been confirmed, So just let me keep the function and in other model can use this function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @seb-elico your input ? |
||
return pricelist |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,11 +42,13 @@ def product_id_change(self): | |
resource.business_requirement_deliverable_id.project_id | ||
if deliverable_project.pricelist_id and \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong. It should use get_estimation_pricelist (of the BR) |
||
deliverable_project.partner_id and resource.uom_id: | ||
pricelist = \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this before the |
||
deliverable_project.get_closest_ancestor_pricelist() | ||
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 | ||
|
@@ -63,11 +65,13 @@ def product_uom_change(self): | |
resource.business_requirement_deliverable_id.project_id | ||
if deliverable_project.pricelist_id and \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same problems here |
||
deliverable_project.partner_id: | ||
pricelist = \ | ||
deliverable_project.get_closest_ancestor_pricelist() | ||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,20 @@ 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 = [] | ||
pricelist = self.project_id.get_closest_ancestor_pricelist() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
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( | ||
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
br.get_estimation_pricelist()