-
Notifications
You must be signed in to change notification settings - Fork 23.1k
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
[IMP] pricelist: pricelist revamp #159746
base: master
Are you sure you want to change the base?
Changes from all commits
aef87c4
f0fe951
d5e897e
3e536fe
3ff289b
7876efe
b15f3ed
b6c3477
d8c18b9
ddb792d
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ class Pricelist(models.Model): | |
_inherit = ['mail.thread', 'mail.activity.mixin'] | ||
_description = "Pricelist" | ||
_rec_names_search = ['name', 'currency_id'] # TODO check if should be removed | ||
_order = "sequence asc, id asc" | ||
_order = "sequence, id, name" | ||
|
||
def _default_currency_id(self): | ||
return self.env.company.currency_id.id | ||
|
@@ -45,16 +45,6 @@ def _default_currency_id(self): | |
tracking=10, | ||
) | ||
|
||
discount_policy = fields.Selection( | ||
selection=[ | ||
('with_discount', "Discount included in the price"), | ||
('without_discount', "Show public price & discount to the customer"), | ||
], | ||
default='with_discount', | ||
required=True, | ||
tracking=15, | ||
) | ||
|
||
item_ids = fields.One2many( | ||
comodel_name='product.pricelist.item', | ||
inverse_name='pricelist_id', | ||
|
@@ -160,6 +150,27 @@ def _get_product_rule(self, product, *args, **kwargs): | |
self and self.ensure_one() # self is at most one record | ||
return self._compute_price_rule(product, *args, compute_price=False, **kwargs)[product.id][1] | ||
|
||
def _get_product_rule_policy(self, product, *args, **kwargs): | ||
"""Compute the pricelist price & rule for the specified product, qty & uom. | ||
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 docstring 👀 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. Well if there's already a pricelist_item_id there wont be a need to recompute it again indeed 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. Only on sales order line for now, we'll have to find another solution for configurator & ecommerce logic. |
||
|
||
Note: self and self.ensure_one() | ||
|
||
:param product: product record (product.product/product.template) | ||
:param float quantity: quantity of products requested (in given uom) | ||
:param currency: record of currency (res.currency) (optional) | ||
:param uom: unit of measure (uom.uom record) (optional) | ||
If not specified, prices returned are expressed in product uoms | ||
:param date: date to use for price computation and currency conversions (optional) | ||
:type date: date or datetime | ||
|
||
:returns: applied pricelist rule id | ||
:rtype: int or False | ||
""" | ||
|
||
self and self.ensure_one() | ||
rule_id = self._get_product_rule(product, *args, **kwargs) | ||
return self.env['product.pricelist.item'].browse(rule_id).compute_price | ||
|
||
def _compute_price_rule( | ||
self, products, quantity, currency=None, uom=None, date=False, compute_price=True, | ||
**kwargs | ||
|
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.
First of all, there is a computed field
pricelist_item_id
that you can use to know the rule that will be used to compute the SOL prices, no need to call the same (costly) method multiple times (and no need to rely on that pricelist context, it should only be used for the price_reduce computation).Also, we'll have to take a look together, but we might have to update the price computation of event tickets & booths, to make it so that it works better with the update pricelist logic