Capacity to product.product and set calculation
This commit is contained in:
parent
67af9bad8e
commit
62626bcbb9
21
product.py
21
product.py
|
@ -46,19 +46,6 @@ 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):
|
||||
|
@ -97,6 +84,14 @@ 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 (self.template.container.capacity * self.wine_alcohol_content) / 100
|
||||
|
||||
@classmethod
|
||||
def validate(cls, products):
|
||||
|
|
|
@ -4,7 +4,5 @@
|
|||
<field name="agronomic_type"/>
|
||||
<label name="container"/>
|
||||
<field name="container"/>
|
||||
<label name="capacity"/>
|
||||
<field name="capacity"/>
|
||||
</xpath>
|
||||
</data>
|
||||
|
|
|
@ -2,6 +2,5 @@
|
|||
<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>
|
||||
|
|
Loading…
Reference in New Issue