Skip to content

[FIX] force factor to be 1 if reference unit#25465

Closed
fmdl wants to merge 1 commit intoodoo:masterfrom
fmdl:patch-77
Closed

[FIX] force factor to be 1 if reference unit#25465
fmdl wants to merge 1 commit intoodoo:masterfrom
fmdl:patch-77

Conversation

@fmdl
Copy link
Copy Markdown
Contributor

@fmdl fmdl commented Jun 25, 2018

Hi @bst-odoo @nim-odoo I don't find the fix for #22025 in master. Please find this following PR.

Description of the issue/feature this PR addresses:
There no constrains to force factor = 1 if it is a reference unit (there is only an onchange). It can be result some wrong compute with _compute_quantity.

Especially for the field product_qty in stock.move, which is a compute field from product_uom_qty. If there are an factor on a Reference unit, the compute will be wrong.

Because _compute_quantity doesn't check if it is a reference or no, and use anyway the stored factor.

https://github.com/odoo/odoo/blob/11.0/addons/product/models/product_uom.py#L92.

Current behavior before PR:

  • import by CSV an unit with : factor= 11, uom_type = 'reference'
  • no error

Desired behavior after PR is merged:

  • import by CSV an unit with : factor= 11, uom_type = 'reference' --> Raise
    image

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

@tde-banana-odoo
Copy link
Copy Markdown
Contributor

cc @jem-odoo

@jem-odoo
Copy link
Copy Markdown
Contributor

@tde-banana-odoo If we are adding this constraint, i would do it in SQL directly, no ?

@mart-e
Copy link
Copy Markdown
Contributor

mart-e commented Aug 23, 2018

Rebased and merged at d5357e4, thanks !

@mart-e mart-e closed this Aug 23, 2018
@mart-e
Copy link
Copy Markdown
Contributor

mart-e commented Aug 23, 2018

oups, sorry @jem-odoo, too slow, feel free to correct

mart-e pushed a commit that referenced this pull request Aug 23, 2018
The _onchange_uom_type was already making sure it was the case but this
constraint ensure it is always the case.

Closes #25465
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.

4 participants