Rename UOM to Unit for product supplier

Closes #2221
This commit is contained in:
Cédric Krier
2023-08-21 09:30:21 +02:00
parent b494a58475
commit d44297eae6
8 changed files with 24 additions and 22 deletions
+1
View File
@@ -1,3 +1,4 @@
* Rename UOM to Unit for product supplier
* Use price from last purchase as product price
* Add a button to create invoices manually
+12 -11
View File
@@ -264,7 +264,7 @@ class Product(metaclass=PoolMeta):
for price in product_supplier.prices:
if price.match(quantity, product_uom, pattern):
unit_price = price.unit_price
default_uom = product_supplier.uom
default_uom = product_supplier.unit
default_currency = product_supplier.currency
if unit_price is not None:
unit_price = Uom.compute_price(
@@ -365,8 +365,8 @@ class ProductSupplier(
"If empty the lead time of the supplier is used.")
currency = fields.Many2One('currency.currency', 'Currency', required=True,
ondelete='RESTRICT')
uom = fields.Function(
fields.Many2One('product.uom', "UOM"), 'on_change_with_uom')
unit = fields.Function(
fields.Many2One('product.uom', "Unit"), 'on_change_with_unit')
@classmethod
def __setup__(cls):
@@ -458,7 +458,7 @@ class ProductSupplier(
@fields.depends(
'product', '_parent_product.purchase_uom',
'template', '_parent_template.purchase_uom')
def on_change_with_uom(self, name=None):
def on_change_with_unit(self, name=None):
if self.product:
return self.product.purchase_uom
elif self.template:
@@ -522,9 +522,10 @@ class ProductSupplierPrice(
unit_price = Monetary(
"Unit Price", currency='currency', required=True, digits=price_digits)
uom = fields.Function(fields.Many2One('product.uom', 'UOM',
help="The unit in which the quantity is specified."),
'on_change_with_uom')
unit = fields.Function(fields.Many2One(
'product.uom', "Unit",
help="The unit in which the quantity is specified."),
'on_change_with_unit')
currency = fields.Function(
fields.Many2One('currency.currency', 'Currency'),
'on_change_with_currency')
@@ -539,8 +540,8 @@ class ProductSupplierPrice(
return 0.0
@fields.depends('product_supplier', '_parent_product_supplier.product')
def on_change_with_uom(self, name=None):
return self.product_supplier.uom if self.product_supplier else None
def on_change_with_unit(self, name=None):
return self.product_supplier.unit if self.product_supplier else None
@fields.depends('product_supplier', '_parent_product_supplier.currency')
def on_change_with_currency(self, name=None):
@@ -551,11 +552,11 @@ class ProductSupplierPrice(
def get_pattern():
return {}
def match(self, quantity, uom, pattern):
def match(self, quantity, unit, pattern):
pool = Pool()
Uom = pool.get('product.uom')
test_quantity = Uom.compute_qty(
self.product_supplier.uom, self.quantity, uom)
self.product_supplier.unit, self.quantity, unit)
if test_quantity > abs(quantity):
return False
return super(ProductSupplierPrice, self).match(pattern)
@@ -29,5 +29,5 @@ this repository contains the full copyright notices and license terms. -->
<field name="currency"/>
<field name="prices" colspan="4"
view_ids="purchase.product_supplier_price_view_list_sequence"/>
<field name="uom" colspan="4" invisible="1"/>
<field name="unit" colspan="4" invisible="1"/>
</form>
@@ -8,7 +8,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="sequence"/>
<label name="quantity"/>
<field name="quantity" symbol="uom"/>
<field name="quantity" symbol="unit"/>
<label name="unit_price"/>
<field name="unit_price"/>
</form>
@@ -3,6 +3,6 @@
this repository contains the full copyright notices and license terms. -->
<tree sequence="sequence" editable="1">
<field name="product_supplier" expand="1"/>
<field name="quantity" symbol="uom"/>
<field name="quantity" symbol="unit"/>
<field name="unit_price" expand="1"/>
</tree>
@@ -3,6 +3,6 @@
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="product_supplier" expand="1"/>
<field name="quantity" symbol="uom"/>
<field name="quantity" symbol="unit"/>
<field name="unit_price"/>
</tree>
+5 -5
View File
@@ -31,7 +31,7 @@ class ProductSupplier(metaclass=PoolMeta):
'on_change_with_quantity_digits')
@fields.depends(
'uom',
'unit',
'product', '_parent_product.default_uom',
'template', '_parent_template.default_uom')
def on_change_with_quantity_digits(self, name=None):
@@ -44,15 +44,15 @@ class ProductSupplier(metaclass=PoolMeta):
else:
return
rounding = default_uom.rounding
if self.uom:
if self.unit:
rounding = Uom.compute_qty(
default_uom, rounding, self.uom, round=False)
default_uom, rounding, self.unit, round=False)
return -Decimal(str(rounding)).as_tuple().exponent
def adapt_quantity(self, quantity, unit, round=True):
pool = Pool()
Uom = pool.get('product.uom')
quantity = Uom.compute_qty(unit, quantity, self.uom, round=False)
quantity = Uom.compute_qty(unit, quantity, self.unit, round=False)
if self.quantity_minimal:
if quantity < self.quantity_minimal:
quantity = self.quantity_minimal
@@ -61,5 +61,5 @@ class ProductSupplier(metaclass=PoolMeta):
quantity % self.quantity_rounding, self.quantity_digits)
if remainder and remainder != self.quantity_rounding:
quantity += (self.quantity_rounding - remainder)
quantity = Uom.compute_qty(self.uom, quantity, unit, round=round)
quantity = Uom.compute_qty(self.unit, quantity, unit, round=round)
return quantity
@@ -4,8 +4,8 @@ this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="//label[@name='currency']" position="before">
<label name="quantity_minimal"/>
<field name="quantity_minimal" symbol="uom"/>
<field name="quantity_minimal" symbol="unit"/>
<label name="quantity_rounding"/>
<field name="quantity_rounding" symbol="uom"/>
<field name="quantity_rounding" symbol="unit"/>
</xpath>
</data>