[18.0][ADD] sale_margin_pricelist_computation: New module#262
Open
Andrii9090-tecnativa wants to merge 1 commit intoOCA:18.0from
Open
[18.0][ADD] sale_margin_pricelist_computation: New module#262Andrii9090-tecnativa wants to merge 1 commit intoOCA:18.0from
Andrii9090-tecnativa wants to merge 1 commit intoOCA:18.0from
Conversation
8a8b834 to
a0b8090
Compare
a0b8090 to
a3a5da7
Compare
a3a5da7 to
94cd816
Compare
94cd816 to
5b28e09
Compare
2 tasks
pedrobaeza
reviewed
Apr 30, 2026
| "for the purposes of margin calculation" | ||
| ) | ||
|
|
||
| def _get_sale_margin_formula_eval_context(self): |
Member
There was a problem hiding this comment.
As this method is only called once, integrate it inside _eval_python_code, as itself it doesn't add value.
| if rec.margin_cost_price_formula: | ||
| self._eval_python_code(rec.margin_cost_price_formula) | ||
|
|
||
| def _eval_python_code(self, test_string): |
Member
There was a problem hiding this comment.
You can put this method as an inner one inside _check_margin_formula, as standalone is not useful. Or at least, use a more specific method name.
| ) | ||
| return super()._compute_margin() | ||
|
|
||
| def _get_eval_context(self): |
Member
There was a problem hiding this comment.
More specific name:
Suggested change
| def _get_eval_context(self): | |
| def _get_margin_pricelist_eval_context(self): |
| for line in self.filtered( | ||
| lambda line: line.pricelist_item_id.margin_sale_price_formula | ||
| ): | ||
| eval_context = line._get_eval_context() |
Member
There was a problem hiding this comment.
Suggested change
| eval_context = line._get_eval_context() | |
| self_formula = self.filtered( | |
| lambda line: line.pricelist_item_id.margin_sale_price_formula | |
| ) | |
| for line in self_formula: |
Comment on lines
+55
to
+57
| self = self.filtered( | ||
| lambda line: not line.pricelist_item_id.margin_sale_price_formula | ||
| ) |
Member
There was a problem hiding this comment.
Suggested change
| self = self.filtered( | |
| lambda line: not line.pricelist_item_id.margin_sale_price_formula | |
| ) | |
| self -= self_formula |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This module extends product pricelists to support Python-based formulas

for computing product cost and product sale price for margin calculations.
@pedrobaeza can you review it?
@Tecnativa
TT62183