[16.0][FIX] product_variant_default_code: avoid unnecessary writes#429
Conversation
|
Hi @Kev-Roche, |
| return None | ||
| else: | ||
| if not self.product_tmpl_id.reference_mask: | ||
| return None |
There was a problem hiding this comment.
Could be simplier:
| return None | |
| def _generate_default_code(self): | |
| value_codes = self.product_tmpl_id.attribute_line_ids.value_ids.mapped("code") | |
| if (not self.code_prefix and self.product_tmpl_id.is_automask()) or not all( | |
| value_codes or not self.product_tmpl_id.reference_mask | |
| ): | |
| return None | |
| else: |
64599e2 to
dd6a477
Compare
Optimize default_code computation to avoid: - Unnecessary write operations when the value hasn't changed - PostgreSQL serialization errors in concurrent transactions - Processing when no reference_mask is defined (early return)
dd6a477 to
a3beb7d
Compare
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
pedrobaeza
left a comment
There was a problem hiding this comment.
Please fw-port it to upper versions:
/ocabot merge patch
|
Hey, thanks for contributing! Proceeding to merge this for you. |
|
@pedrobaeza your merge command was aborted due to failed check(s), which you can inspect on this commit of 16.0-ocabot-merge-pr-429-by-pedrobaeza-bump-patch. After fixing the problem, you can re-issue a merge command. Please refrain from merging manually as it will most probably make the target branch red. |
|
Retrying after #442 /ocabot merge patch |
|
What a great day to merge this nice PR. Let's do it! |
|
Congratulations, your PR was merged at a72e6de. Thanks a lot for contributing to OCA. ❤️ |
Description
Optimizes the default_code computation in product variants:
Avoid unnecessary writes: Only writes to default_code when the value actually changes. in db with many products makes upgrades faster
Early return without reference_mask: Returns None early in
_generate_default_code()when no reference_mask is defined, avoiding unnecessary processing, that was causing error during upgrades when database already contain many products and no automask setting is onTesting
Checklist