-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct.py
39 lines (29 loc) · 1.18 KB
/
product.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from trytond.model import fields
from trytond.pool import Pool, PoolMeta
from trytond.pyson import Eval
from trytond.transaction import Transaction
class Template(metaclass=PoolMeta):
__name__ = 'product.template'
supply_production_on_sale = fields.Boolean('Supply Production On Sale',
states={
'invisible': ~Eval('producible'),
})
@classmethod
def __register__(cls, module_name):
handler = cls.__table_handler__(module_name)
existing = handler.column_exist('supply_production_on_sale')
super().__register__(module_name)
if not existing:
Config = Pool().get('sale.configuration')
config = Config(1)
if config.sale_supply_production_default:
table = cls.__table__()
cursor = Transaction().connection.cursor()
cursor.execute(*table.update(
columns=[table.supply_production_on_sale],
values=[True],
where=table.producible == True))
class Product(metaclass=PoolMeta):
__name__ = 'product.product'
def get_bom(self):
return self.boms and self.boms[0]