Revert "Capacity to product.product and set calculation"

This reverts commit 62626bcbb9.
This commit is contained in:
Raimon Esteve 2021-07-16 11:33:25 +02:00
parent a3e97d232d
commit e85cd62e35
3 changed files with 16 additions and 8 deletions

View File

@ -47,6 +47,19 @@ class Template(metaclass=PoolMeta):
states={
'invisible': Eval('agronomic_type') != 'bottled-wine',
}, depends=['agronomic_type'])
capacity = fields.Function(fields.Numeric('Capacity', digits=(16, 2),
states={
'invisible': Eval('agronomic_type') != 'bottled-wine',
}, depends=['agronomic_type']), 'get_capacity',
searcher='search_capacity')
def get_capacity(self, name):
if self.container:
return self.container.capacity
@classmethod
def search_capacity(cls, name, clause):
return [('container.capacity',) + tuple(clause[1:])]
class Product(WineMixin, metaclass=PoolMeta):
@ -85,14 +98,6 @@ class Product(WineMixin, metaclass=PoolMeta):
['wine', 'unfiltered-wine', 'filtered-wine', 'clarified-wine',
'bottled-wine']
)}, depends=['agronomic_type'])
capacity = fields.Function(fields.Numeric('Capacity', digits=(16, 2),
states={
'invisible': Eval('agronomic_type') != 'bottled-wine',
}, depends=['agronomic_type']), 'get_capacity')
def get_capacity(self, name):
if self.template.container and self.wine_alcohol_content:
return Decimal((float(self.template.container.capacity) * float(self.wine_alcohol_content)) / 100)
@classmethod
def validate(cls, products):

View File

@ -4,5 +4,7 @@
<field name="agronomic_type"/>
<label name="container"/>
<field name="container"/>
<label name="capacity"/>
<field name="capacity"/>
</xpath>
</data>

View File

@ -2,5 +2,6 @@
<xpath expr="/tree" position="inside">
<field name="agronomic_type" tree_invisible="1"/>
<field name="container" tree_invisible="1"/>
<field name="capacity" tree_invisible="1"/>
</xpath>
</data>