changeset 18f23b78c468 in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=18f23b78c468
description:
Provide digits from unit of measure
issue10677
review365801002
diffstat:
delivery_note.fodt | 4 ++--
internal_shipment.fodt | 4 ++--
inventory.py | 30 ++++++------------------------
move.py | 19 +++----------------
picking_list.fodt | 4 ++--
stock_reporting_margin.py | 8 +-------
supplier_restocking_list.fodt | 4 ++--
view/move_form.xml | 2 --
8 files changed, 18 insertions(+), 57 deletions(-)
diffs (238 lines):
diff -r 12947abae57e -r 18f23b78c468 delivery_note.fodt
--- a/delivery_note.fodt Fri Aug 27 08:59:26 2021 +0200
+++ b/delivery_note.fodt Mon Aug 30 00:27:13 2021 +0200
@@ -475,7 +475,7 @@
<text:p text:style-name="P13"><text:placeholder
text:placeholder-type="text"><move.product.rec_name></text:placeholder></text:p>
</table:table-cell>
<table:table-cell table:style-name="Table1.B3" office:value-type="string">
- <text:p text:style-name="P12"><text:placeholder
text:placeholder-type="text"><format_number(move.quantity,
shipment.delivery_address.party.lang,
digits=move.unit_digits)></text:placeholder><text:s/><text:placeholder
text:placeholder-type="text"><move.uom.symbol></text:placeholder></text:p>
+ <text:p text:style-name="P12"><text:placeholder
text:placeholder-type="text"><format_number(move.quantity,
shipment.delivery_address.party.lang,
digits=move.uom.digits)></text:placeholder><text:s/><text:placeholder
text:placeholder-type="text"><move.uom.symbol></text:placeholder></text:p>
</table:table-cell>
</table:table-row>
<table:table-row>
@@ -488,4 +488,4 @@
<text:p text:style-name="P9"><text:placeholder
text:placeholder-type="text"></for></text:placeholder></text:p>
</office:text>
</office:body>
-</office:document>
\ No newline at end of file
+</office:document>
diff -r 12947abae57e -r 18f23b78c468 internal_shipment.fodt
--- a/internal_shipment.fodt Fri Aug 27 08:59:26 2021 +0200
+++ b/internal_shipment.fodt Mon Aug 30 00:27:13 2021 +0200
@@ -506,7 +506,7 @@
<text:p text:style-name="Table_20_Contents"><text:placeholder
text:placeholder-type="text"><move.product.rec_name></text:placeholder></text:p>
</table:table-cell>
<table:table-cell table:style-name="Table1.D4" office:value-type="string">
- <text:p text:style-name="P11"><text:placeholder
text:placeholder-type="text"><format_number(move.quantity, user.language,
digits=move.unit_digits)></text:placeholder><text:s/><text:placeholder
text:placeholder-type="text"><move.uom.symbol></text:placeholder></text:p>
+ <text:p text:style-name="P11"><text:placeholder
text:placeholder-type="text"><format_number(move.quantity, user.language,
digits=move.uom.digits)></text:placeholder><text:s/><text:placeholder
text:placeholder-type="text"><move.uom.symbol></text:placeholder></text:p>
</table:table-cell>
</table:table-row>
<table:table-row>
@@ -525,4 +525,4 @@
<text:p text:style-name="Text_20_body"><text:placeholder
text:placeholder-type="text"></for></text:placeholder></text:p>
</office:text>
</office:body>
-</office:document>
\ No newline at end of file
+</office:document>
diff -r 12947abae57e -r 18f23b78c468 inventory.py
--- a/inventory.py Fri Aug 27 08:59:26 2021 +0200
+++ b/inventory.py Mon Aug 30 00:27:13 2021 +0200
@@ -328,18 +328,14 @@
], states=_states, depends=_depends)
uom = fields.Function(fields.Many2One('product.uom', 'UOM',
help="The unit in which the quantity is specified."), 'get_uom')
- unit_digits = fields.Function(fields.Integer('Unit Digits'),
- 'get_unit_digits')
- expected_quantity = fields.Float('Expected Quantity', required=True,
- digits=(16, Eval('unit_digits', 2)), readonly=True,
+ expected_quantity = fields.Float(
+ "Expected Quantity", digits='uom', required=True, readonly=True,
states={
'invisible': Eval('id', -1) < 0,
},
- depends=['unit_digits'],
help="The quantity the system calculated should be in the location.")
- quantity = fields.Float('Quantity',
- digits=(16, Eval('unit_digits', 2)),
- states=_states, depends=['unit_digits'] + _depends,
+ quantity = fields.Float(
+ "Quantity", digits='uom', states=_states, depends=_depends,
help="The actual quantity found in the location.")
moves = fields.One2Many('stock.move', 'origin', 'Moves', readonly=True)
inventory = fields.Many2One('stock.inventory', 'Inventory', required=True,
@@ -402,19 +398,13 @@
table.not_null_action('quantity', action='remove')
@staticmethod
- def default_unit_digits():
- return 2
-
- @staticmethod
def default_expected_quantity():
return 0.
@fields.depends('product')
def on_change_product(self):
- self.unit_digits = 2
if self.product:
self.uom = self.product.default_uom
- self.unit_digits = self.product.default_uom.digits
@fields.depends('inventory', '_parent_inventory.location')
def on_change_with_inventory_location(self, name=None):
@@ -457,9 +447,6 @@
def get_uom(self, name):
return self.product.default_uom.id
- def get_unit_digits(self, name):
- return self.product.default_uom.digits
-
@property
def unique_key(self):
key = []
@@ -594,7 +581,6 @@
values['line'] = line.id
values['product'] = line.product.id
values['uom'] = line.uom.id
- values['unit_digits'] = line.unit_digits
if line.uom.rounding == 1:
values['quantity'] = 1
return values
@@ -674,17 +660,13 @@
uom = fields.Many2One('product.uom', "UOM", readonly=True,
help="The unit in which the quantities are specified.")
total_quantity = fields.Float(
- "Total Quantity", digits=(16, Eval('unit_digits', 2)),
- readonly=True, depends=['unit_digits'],
+ "Total Quantity", digits='uom', readonly=True,
help="The total amount of the line counted so far.")
quantity = fields.Float(
- "Quantity", digits=(16, Eval('unit_digits', 2)), required=True,
- depends=['unit_digits'],
+ "Quantity", digits='uom', required=True,
help="The quantity to add to the existing count.")
- unit_digits = fields.Integer("Unit Digits", readonly=True)
-
@fields.depends('quantity', 'line')
def on_change_quantity(self):
if self.line:
diff -r 12947abae57e -r 18f23b78c468 move.py
--- a/move.py Fri Aug 27 08:59:26 2021 +0200
+++ b/move.py Mon Aug 30 00:27:13 2021 +0200
@@ -192,11 +192,9 @@
],
depends=['state', 'unit_price', 'product_uom_category'],
help="The unit in which the quantity is specified.")
- unit_digits = fields.Function(fields.Integer('Unit Digits'),
- 'on_change_with_unit_digits')
- quantity = fields.Float("Quantity", required=True,
- digits=(16, Eval('unit_digits', 2)), states=STATES,
- depends=['state', 'unit_digits'],
+ quantity = fields.Float(
+ "Quantity", digits='uom', required=True,
+ states=STATES, depends=DEPENDS,
help="The amount of stock moved.")
internal_quantity = fields.Float('Internal Quantity', readonly=True,
required=True)
@@ -408,23 +406,12 @@
company = Company(company)
return company.currency.id
- @staticmethod
- def default_unit_digits():
- return 2
-
- @fields.depends('uom')
- def on_change_with_unit_digits(self, name=None):
- if self.uom:
- return self.uom.digits
- return 2
-
@fields.depends('product', 'uom')
def on_change_product(self):
if self.product:
if (not self.uom
or self.uom.category != self.product.default_uom.category):
self.uom = self.product.default_uom
- self.unit_digits = self.product.default_uom.digits
@fields.depends('product')
def on_change_with_product_uom_category(self, name=None):
diff -r 12947abae57e -r 18f23b78c468 picking_list.fodt
--- a/picking_list.fodt Fri Aug 27 08:59:26 2021 +0200
+++ b/picking_list.fodt Mon Aug 30 00:27:13 2021 +0200
@@ -468,7 +468,7 @@
<text:p text:style-name="Table_20_Contents"><text:placeholder
text:placeholder-type="text"><move.product.rec_name></text:placeholder></text:p>
</table:table-cell>
<table:table-cell table:style-name="Table1.D4" office:value-type="string">
- <text:p text:style-name="P12"><text:placeholder
text:placeholder-type="text"><format_number(move.quantity, user.language,
digits=move.unit_digits)></text:placeholder> <text:placeholder
text:placeholder-type="text"><move.uom.symbol></text:placeholder></text:p>
+ <text:p text:style-name="P12"><text:placeholder
text:placeholder-type="text"><format_number(move.quantity, user.language,
digits=move.uom.digits)></text:placeholder> <text:placeholder
text:placeholder-type="text"><move.uom.symbol></text:placeholder></text:p>
</table:table-cell>
</table:table-row>
<table:table-row>
@@ -487,4 +487,4 @@
<text:p text:style-name="Text_20_body"><text:placeholder
text:placeholder-type="text"></for></text:placeholder></text:p>
</office:text>
</office:body>
-</office:document>
\ No newline at end of file
+</office:document>
diff -r 12947abae57e -r 18f23b78c468 stock_reporting_margin.py
--- a/stock_reporting_margin.py Fri Aug 27 08:59:26 2021 +0200
+++ b/stock_reporting_margin.py Mon Aug 30 00:27:13 2021 +0200
@@ -344,11 +344,8 @@
depends=['company'])
internal_quantity = fields.Float("Internal Quantity")
quantity = fields.Function(fields.Float(
- "Quantity", digits=(16, Eval('unit_digits', 2)),
- depends=['unit_digits']), 'get_quantity')
+ "Quantity", digits='unit'), 'get_quantity')
unit = fields.Function(fields.Many2One('product.uom', "Unit"), 'get_unit')
- unit_digits = fields.Function(
- fields.Integer("Unit Digits"), 'get_unit_digits')
@classmethod
def _columns(cls, tables, withs):
@@ -379,9 +376,6 @@
def get_unit(self, name):
return self.product.default_uom.id
- def get_unit_digits(self, name):
- return self.product.default_uom.digits
-
class Product(ProductMixin, Abstract, ModelView):
"Stock Reporting Margin per Product"
diff -r 12947abae57e -r 18f23b78c468 supplier_restocking_list.fodt
--- a/supplier_restocking_list.fodt Fri Aug 27 08:59:26 2021 +0200
+++ b/supplier_restocking_list.fodt Mon Aug 30 00:27:13 2021 +0200
@@ -460,7 +460,7 @@
<text:p text:style-name="Table_20_Contents"><text:placeholder
text:placeholder-type="text"><move.product.rec_name></text:placeholder></text:p>
</table:table-cell>
<table:table-cell table:style-name="Table1.D4" office:value-type="string">
- <text:p text:style-name="P11"><text:placeholder
text:placeholder-type="text"><format_number(move.quantity, user.language,
digits=move.unit_digits)></text:placeholder> <text:placeholder
text:placeholder-type="text"><move.uom.symbol></text:placeholder></text:p>
+ <text:p text:style-name="P11"><text:placeholder
text:placeholder-type="text"><format_number(move.quantity, user.language,
digits=move.uom.digits)></text:placeholder> <text:placeholder
text:placeholder-type="text"><move.uom.symbol></text:placeholder></text:p>
</table:table-cell>
</table:table-row>
<table:table-row>
@@ -479,4 +479,4 @@
<text:p text:style-name="Text_20_body"><text:placeholder
text:placeholder-type="text"></for></text:placeholder></text:p>
</office:text>
</office:body>
-</office:document>
\ No newline at end of file
+</office:document>
diff -r 12947abae57e -r 18f23b78c468 view/move_form.xml
--- a/view/move_form.xml Fri Aug 27 08:59:26 2021 +0200
+++ b/view/move_form.xml Mon Aug 30 00:27:13 2021 +0200
@@ -33,6 +33,4 @@
<button name="draft" icon="tryton-clear"/>
<button name="do" icon="tryton-forward"/>
</group>
- <field name="unit_price_required" invisible="1" colspan="4"/>
- <field name="unit_digits" invisible="1" colspan="4"/>
</form>