Skip to content
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

[13.0][OU-ADD] stock_picking_responsible: merged into stock #4238

Merged

Conversation

robinkeunen
Copy link
Contributor

responsible_id field in stock_picking_responsible is replaced by user_id in stock. The script migrates data from

# stock_picking_responsible/models/stock_picking.py
responsible_id = fields.Many2one(
    comodel_name="res.partner",
    string="Responsible",
    default=lambda self: self.env.user.partner_id.id,
)

to

# stock/models/stock_picking.py
user_id = fields.Many2one(
    'res.users', 'Responsible', tracking=True,
    domain=lambda self: [('groups_id', 'in', self.env.ref('stock.group_stock_user').id)],
    states={'done': [('readonly', True)], 'cancel': [('readonly', True)]},
    default=lambda self: self.env.user)

First PR on OpenUpgrade, comments welcome.

We copy the legacy column to convert data in post-migration script.
"""
if openupgrade.column_exists(env.cr, "stock_picking", "responsible_id"):
openupgrade.copy_columns(
Copy link
Member

Choose a reason for hiding this comment

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

No need to copy or rename the column. It's going to be there in post.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it as you suggested, should we just leave the responsible_id in the database ?

)
partner_wo_user = env.cr.fetchall()
for picking_id, picking_name, partner_id, partner_name in partner_wo_user:
_logger.warning(
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this, what about creating a disabled user and fill it with it?

@robinkeunen robinkeunen force-pushed the 13.0-merge-stock_pickibg_responsible branch 4 times, most recently from bbbb2e8 to 4f00042 Compare November 28, 2023 15:45
@robinkeunen robinkeunen force-pushed the 13.0-merge-stock_pickibg_responsible branch from 4f00042 to 8d44dea Compare November 29, 2023 09:21
@robinkeunen
Copy link
Contributor Author

Here you go Pedro, thank you for the review and suggestions :-)

@pedrobaeza pedrobaeza merged commit f269077 into OCA:13.0 Nov 29, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants