Skip to content

[19.0] [MIG] stock_operating_unit: Migration to 19.0 - #862

Open
Borruso wants to merge 49 commits into
OCA:19.0from
Borruso:19.0-mig-stock_operating_unit
Open

Borruso wants to merge 49 commits into
OCA:19.0from
Borruso:19.0-mig-stock_operating_unit

Conversation

@Borruso

@Borruso Borruso commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

JordiBForgeFlow and others added 30 commits July 8, 2026 17:09
* 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
@OCA-git-bot OCA-git-bot added series:19.0 mod:stock_operating_unit Module stock_operating_unit labels Jul 8, 2026
@Borruso
Borruso force-pushed the 19.0-mig-stock_operating_unit branch 7 times, most recently from e275d0a to 3c36a05 Compare July 9, 2026 11:30
@AaronHForgeFlow

Copy link
Copy Markdown
Contributor

/ocabot migration stock_operating_unit

@OCA-git-bot OCA-git-bot added this to the 19.0 milestone Jul 22, 2026
@OCA-git-bot OCA-git-bot mentioned this pull request Jul 22, 2026
12 tasks
operating_unit_id = fields.Many2one(
comodel_name="operating.unit",
string="Operating Unit",
default=lambda self: self._default_operating_unit(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@BhaveshHeliconia

Copy link
Copy Markdown
Contributor

could you please check the failing test/ci?

@Borruso
Borruso force-pushed the 19.0-mig-stock_operating_unit branch 3 times, most recently from 2ec1bf7 to d8438e7 Compare September 15, 2026 07:58
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]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Borruso force-pushed the 19.0-mig-stock_operating_unit branch from d8438e7 to a383dbd Compare September 15, 2026 13:13
@BhaveshHeliconia

Copy link
Copy Markdown
Contributor

could you please check the failing test/ci?

@Borruso
Borruso force-pushed the 19.0-mig-stock_operating_unit branch from a383dbd to d3a4ca9 Compare September 16, 2026 08:02
@Borruso
Borruso force-pushed the 19.0-mig-stock_operating_unit branch from d3a4ca9 to 19f0fa7 Compare September 16, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:stock_operating_unit Module stock_operating_unit series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.