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

[FIX] stock: avoid write on move when create return line #77100

Conversation

hoangtrann
Copy link
Contributor

When creating a wizard stock.return.picking and call
_onchange_picking_id, the creation of return picking line will perform
a write on move linked with it, due to uom_id being set as related with
readonly=False. Set readonly to True to avoid it

This starts with #76923

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo
Copy link
Contributor

robodoo commented Sep 23, 2021

@hoangtrann
Copy link
Contributor Author

cc @fmdl @ticodoo @ryv-odoo

Copy link
Contributor

@ticodoo ticodoo left a comment

Choose a reason for hiding this comment

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

Looks good to me, just change the related value so it's consistent with the later versions. Thank you!

@@ -14,7 +14,7 @@ class ReturnPickingLine(models.TransientModel):

product_id = fields.Many2one('product.product', string="Product", required=True, domain="[('id', '=', product_id)]")
quantity = fields.Float("Quantity", digits=dp.get_precision('Product Unit of Measure'), required=True)
uom_id = fields.Many2one('uom.uom', string='Unit of Measure', related='move_id.product_uom', readonly=False)
uom_id = fields.Many2one('uom.uom', string='Unit of Measure', related='move_id.product_uom')
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
uom_id = fields.Many2one('uom.uom', string='Unit of Measure', related='move_id.product_uom')
uom_id = fields.Many2one('uom.uom', string='Unit of Measure', related='product_id.uom_id')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ticodoo updated the related value and added a test in case of outgoing move's uom is different from product's uom

When creating a wizard `stock.return.picking` and call
`_onchange_picking_id`, the creation of return picking line will perform
a write on move linked with it, due to `uom_id` being set as related with
`readonly=False`. Set `readonly` to `True` to avoid it
@hoangtrann hoangtrann force-pushed the saas-12.3-fix-onchange-trigger-write-on-related-model-hoangtrann branch from 5cee017 to 006fa29 Compare September 24, 2021 09:04
@ticodoo
Copy link
Contributor

ticodoo commented Sep 24, 2021

Thank you for your contribution!
@robodoo r+

robodoo pushed a commit that referenced this pull request Sep 24, 2021
When creating a wizard `stock.return.picking` and call
`_onchange_picking_id`, the creation of return picking line will perform
a write on move linked with it, due to `uom_id` being set as related with
`readonly=False`. Set `readonly` to `True` to avoid it

closes #77100

Signed-off-by: Tiffany Chang <tic@odoo.com>
@robodoo robodoo closed this Sep 24, 2021
@robodoo robodoo temporarily deployed to merge September 24, 2021 11:21 Inactive
@fw-bot
Copy link
Contributor

fw-bot commented Sep 28, 2021

This pull request has forward-port PRs awaiting action (not merged or closed): #77231, #77235

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.

None yet

4 participants