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

Using measure_type instead of type #489

Open
victor-champonnois opened this issue Dec 14, 2022 · 0 comments
Open

Using measure_type instead of type #489

victor-champonnois opened this issue Dec 14, 2022 · 0 comments

Comments

@victor-champonnois
Copy link
Member

victor-champonnois commented Dec 14, 2022

This file adds the type fields to uom.category.

class UOMCategory(models.Model):
_inherit = "uom.category"
type = fields.Selection(
[
("unit", "Unit"),
("weight", "Weight"),
("time", "Time"),
("distance", "Distance"),
("surface", "Surface"),
("volume", "Volume"),
("other", "Other"),
],
string="Category type",
default="unit",

It is used to compute the product_scale_unit.
def _compute_scale_sale_uom(self):
for product in self:
if product.uom_id.category_id.type == "unit":
product.scale_sale_unit = "F"
elif product.uom_id.category_id.type == "weight":
product.scale_sale_unit = "P"

However, there exists already a measure_type field, with almost the same content.

https://github.com/OCA/OCB/blob/daa274eb48324d563e1096e334a5a73034be71dc/addons/uom/models/uom_uom.py#L13

Both are displayed in the view.
image

Should we get rid of type to replace it with measure_type ?
This would need a migration script.

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

No branches or pull requests

1 participant