-
-
Notifications
You must be signed in to change notification settings - Fork 694
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
16.0 mig base product mass addition #1393
Closed
aiendry-aktivsoftware
wants to merge
43
commits into
OCA:16.0
from
aiendry-aktivsoftware:16.0-mig-base_product_mass_addition
Closed
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
a0c4247
[ADD] module base_product_mass_addition
2193753
[IMP] do not depend on arbitrary view
7e3bbde
[IMP] make implementations intercompatible
9e69234
IMP ui and refactor action
bealdav 46f6146
[FIX] Remove non model-agnostic filter
ab8ba5b
[UPD] README.rst
OCA-git-bot e394391
[UPD] Update base_product_mass_addition.pot
oca-travis 6051cc6
[ADD] icon.png
OCA-git-bot 590cd49
[UPD] README.rst
OCA-git-bot 071dcf5
[IMP] base_product_mass_addition: black, isort
phuctranfxvn 73061d9
[MIG] base_product_mass_addition: Migration to 13.0
phuctranfxvn d58eaae
[IMP] base_product_mass_addition: black, isort, prettier
03cfca9
[MIG] base_product_mass_addition: Migration to 14.0
631d087
[IMP] optionnaly use onchange_helper
e6022ab
[IMP] depend on onchange_helper
ae4015f
[UPD] Update base_product_mass_addition.pot
oca-travis d5e8afc
[UPD] README.rst
OCA-git-bot 5fde75a
[IMP] Add UoM functionality, simplify some code
kevinkhao 0ff0fa8
[IMP] Remove purchase-specific element in function name
kevinkhao 771dfd1
[IMP] Add access rights hack so that users that don't have write acce…
kevinkhao f700523
[IMP] Remove useless _sync_quick_lines() intermediary
kevinkhao f335e37
[IMP] use related on quick_uom_category_id
kevinkhao 6700572
[REF] Remove permissions for users that cannot edit product.product. …
kevinkhao fdea025
[REF] Remove dead code
kevinkhao 6440da6
[REV] Revert rename of _inverse_set_process_qty
kevinkhao 918cb6d
[UPD] Update base_product_mass_addition.pot
oca-travis 4bb8386
[UPD] README.rst
OCA-git-bot 7f77ba8
base_product_mass_addition 14.0.1.1.0
OCA-git-bot 54b2c93
Added translation using Weblate (French)
Kev-Roche fec9f63
Translated using Weblate (French)
Kev-Roche fd4a066
Translated using Weblate (French)
Kev-Roche f30c4ca
[IMP] base_product_mass_addition: avoid writing on product access fields
ivantodorovich 63452ac
[IMP] base_product_mass_addition: Add unit tests
ivantodorovich c647b9b
[UPD] README.rst
OCA-git-bot 515f93f
base_product_mass_addition 14.0.1.2.0
OCA-git-bot 665b50c
[MIG]base_product_mass_addition: Migration to 15.0
d88f9ec
[UPD] Update base_product_mass_addition.pot
76745c2
[UPD] README.rst
OCA-git-bot d342143
Update translation files
weblate f25414c
Added translation using Weblate (Spanish)
luis-ron 7426c45
Translated using Weblate (Spanish)
luis-ron 9379dac
[IMP] base_product_mass_addition: pre-commit stuff
aiendry-aktivsoftware 936f18a
[MIG] base_product_mass_addition: Migration to 16.0
aiendry-aktivsoftware File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,6 +26,7 @@ class ProductProduct(models.Model): | |||||
domain="[('category_id', '=', quick_uom_category_id)]", | ||||||
compute="_compute_quick_uom_id", | ||||||
inverse="_inverse_set_process_qty", | ||||||
store=True, | ||||||
) | ||||||
|
||||||
def _inverse_set_process_qty(self): | ||||||
|
@@ -38,41 +39,34 @@ def _inverse_set_process_qty(self): | |||||
else: | ||||||
parent._add_quick_line(product, quick_line._name) | ||||||
|
||||||
def modified(self, fnames, create=False, before=False): | ||||||
def write(self, vals): | ||||||
# OVERRIDE to supress LOG_ACCESS_COLUMNS writes if we're only writing on quick | ||||||
# magic fields, as they could lead to concurrency issues. | ||||||
# | ||||||
# Moreover, from a functional perspective, these magic fields aren't really | ||||||
# modifying the product's data so it doesn't make sense to update its metadata. | ||||||
# | ||||||
# We achieve it by reverting the changes made by ``write`` [^1], before [^2] | ||||||
# reaching any explicit flush [^3] or inverse computation [^4]. | ||||||
# We achieve it by stopping the ``write`` [^1] to modify LOG_ACCESS_COLUMNS. | ||||||
# By changing the log access rights ``_log_access`` | ||||||
# | ||||||
# [^1]: | ||||||
# https://github.com/odoo/odoo/blob/3991737a53e75398fcf70b1924525783b54d256b/odoo/models.py#L3778-L3787 # noqa: B950 | ||||||
# [^2]: | ||||||
# https://github.com/odoo/odoo/blob/3991737a53e75398fcf70b1924525783b54d256b/odoo/models.py#L3882 # noqa: B950 | ||||||
# [^3]: | ||||||
# https://github.com/odoo/odoo/blob/3991737a53e75398fcf70b1924525783b54d256b/odoo/models.py#L3885 # noqa: B950 | ||||||
# [^4]: | ||||||
# https://github.com/odoo/odoo/blob/f74434c6f4303650e886d99fb950c763f2d4cc6e/odoo/models.py#L3703 # noqa: B950 | ||||||
# https://github.com/odoo/odoo/blob/dab802a939c97603f70c504e98ecc92b0ac552f9/odoo/models.py#L3677C1-L3679C61 # noqa: B950 | ||||||
# | ||||||
# Basically, if all we're modifying are quick magic fields, and we don't have | ||||||
# any other column to flush besides the LOG_ACCESS_COLUMNS, clear it. | ||||||
quick_fnames = ("qty_to_process", "quick_uom_id") | ||||||
if ( | ||||||
self | ||||||
and fnames | ||||||
and any(quick_fname in fnames for quick_fname in quick_fnames) | ||||||
): | ||||||
for record in self.filtered("id"): | ||||||
towrite = self.env.all.towrite[self._name] | ||||||
vals = towrite[record.id] | ||||||
if not vals: # pragma: no cover | ||||||
continue | ||||||
if all(fname in LOG_ACCESS_COLUMNS for fname in vals.keys()): | ||||||
towrite.pop(record.id) | ||||||
return super().modified(fnames, create=create, before=before) | ||||||
if self and any(quick_fname in vals.keys() for quick_fname in quick_fnames): | ||||||
cr = self.env.cr | ||||||
Model = self._build_model(self.pool, cr) | ||||||
Model._auto = False | ||||||
Model._log_access = set(list([])) | ||||||
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.
Suggested change
is the same, no ? |
||||||
res = super(ProductProduct, self).write(vals) | ||||||
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.
Suggested change
|
||||||
if not self._log_access: | ||||||
cr = self.env.cr | ||||||
Model = self._build_model(self.pool, cr) | ||||||
Model._auto = True | ||||||
Model._log_access = set(LOG_ACCESS_COLUMNS) | ||||||
return res | ||||||
|
||||||
@property | ||||||
def pma_parent(self): | ||||||
|
@@ -83,7 +77,7 @@ def pma_parent(self): | |||||
return self.env[parent_model].browse(parent_id) | ||||||
|
||||||
def _default_quick_uom_id(self): | ||||||
raise NotImplementedError | ||||||
raise NotImplementedError() | ||||||
|
||||||
def _compute_quick_uom_id(self): | ||||||
parent = self.pma_parent | ||||||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ Akretion | |
* `Sygel <https://www.sygel.es>`_: | ||
|
||
* Ángel García de la Chica Herrera <[email protected]> | ||
* Aiendry Sarkar <[email protected]> |
This file contains 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
Oops, something went wrong.
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.
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.
issue: you try to store a field that should be computed on the fly, and not be stored. I guess something is wrong with that design. could you explain that change ? Thanks !
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.
This is the issue without
store=True
It seems there is some kind of dependency race on this.
However I'm not sure there is a need to have the
quick_uom_category_id
field since it's not use anywhere in the module and it could be accessed viaquick_uom_id.category_id
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.
By the way the
store=True
breaks functionnality on downstream module it sometimes lead to a None valued uom_id on the product