Conversation
* Replace <openerp> and <data> elements by <odoo> * Remove spaces in strings introduced because of \ * Remove exclamation points in error messages * Remove most of the \ where it can be replaced by parenthesis
Borruso
force-pushed
the
19.0-mig-stock_operating_unit
branch
7 times, most recently
from
July 9, 2026 11:30
e275d0a to
3c36a05
Compare
Contributor
|
/ocabot migration stock_operating_unit |
| operating_unit_id = fields.Many2one( | ||
| comodel_name="operating.unit", | ||
| string="Operating Unit", | ||
| default=lambda self: self._default_operating_unit(), |
Contributor
There was a problem hiding this comment.
Suggested change
| default=lambda self: self._default_operating_unit(), | |
| default=lambda self: self.env["res.users"]._get_default_operating_unit(), |
The custom method _default_operating_unit() in StockWarehouse does not return a value (it sets self.operating_unit_id = ou and returns None), and the condition company == self.company_id evaluates to False on empty new recordsets.
We can remove _default_operating_unit() and use the standard helper from the base operating_unit module directly on the field
Contributor
|
could you please check the failing test/ci? |
Borruso
force-pushed
the
19.0-mig-stock_operating_unit
branch
3 times, most recently
from
September 15, 2026 07:58
2ec1bf7 to
d8438e7
Compare
Comment on lines
+11
to
+19
| @api.model | ||
| def _default_operating_unit(self, company=False): | ||
| company = company or self.env.company | ||
| default_ou = self.env.user.default_operating_unit_id.sudo() | ||
| if default_ou.company_id == company: | ||
| return default_ou | ||
| return self.env.user.operating_unit_ids.sudo().filtered( | ||
| lambda ou: ou.company_id == company | ||
| )[:1] |
Contributor
There was a problem hiding this comment.
Suggested change
| @api.model | |
| def _default_operating_unit(self, company=False): | |
| company = company or self.env.company | |
| default_ou = self.env.user.default_operating_unit_id.sudo() | |
| if default_ou.company_id == company: | |
| return default_ou | |
| return self.env.user.operating_unit_ids.sudo().filtered( | |
| lambda ou: ou.company_id == company | |
| )[:1] |
Borruso
force-pushed
the
19.0-mig-stock_operating_unit
branch
from
September 15, 2026 13:13
d8438e7 to
a383dbd
Compare
Contributor
|
could you please check the failing test/ci? |
Borruso
force-pushed
the
19.0-mig-stock_operating_unit
branch
from
September 16, 2026 08:02
a383dbd to
d3a4ca9
Compare
Borruso
force-pushed
the
19.0-mig-stock_operating_unit
branch
from
September 16, 2026 08:06
d3a4ca9 to
19f0fa7
Compare
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.
#802