Add UOM and sequence fields.
This commit is contained in:
parent
6b935b2e7c
commit
f615c5b488
29
plan.py
29
plan.py
|
@ -23,6 +23,18 @@ class Plan(Workflow, ModelSQL, ModelView):
|
|||
states={
|
||||
'readonly': Eval('state') != 'draft',
|
||||
}, depends=['state'], on_change=['product', 'bom', 'boms'])
|
||||
uom = fields.Many2One('product.uom', 'UOM', required=True, domain=[
|
||||
If(Bool(Eval('product_uom_category')),
|
||||
('category', '=', Eval('product_uom_category')),
|
||||
(),
|
||||
)],
|
||||
states={
|
||||
'readonly': Bool(Eval('product')),
|
||||
}, depends=['product_uom_category', 'product'])
|
||||
product_uom_category = fields.Function(
|
||||
fields.Many2One('product.uom.category', 'Product Uom Category',
|
||||
on_change_with=['product']),
|
||||
'on_change_with_product_uom_category')
|
||||
bom = fields.Many2One('production.bom', 'BOM', on_change_with=['product'],
|
||||
states={
|
||||
'readonly': Eval('state') != 'draft',
|
||||
|
@ -83,6 +95,8 @@ class Plan(Workflow, ModelSQL, ModelView):
|
|||
bom = self.on_change_with_bom()
|
||||
self.bom = bom
|
||||
res['boms'] = self.on_change_with_boms()
|
||||
if self.product:
|
||||
res['uom'] = self.product.default_uom.id
|
||||
return res
|
||||
|
||||
def on_change_with_bom(self):
|
||||
|
@ -149,6 +163,10 @@ class Plan(Workflow, ModelSQL, ModelView):
|
|||
def on_change_with_cost_price(self, name=None):
|
||||
return sum(c.cost for c in self.costs if c.cost)
|
||||
|
||||
def on_change_with_product_uom_category(self, name=None):
|
||||
if self.product:
|
||||
return self.product.default_uom_category.id
|
||||
|
||||
@classmethod
|
||||
def create(cls, vlist):
|
||||
Sequence = Pool().get('ir.sequence')
|
||||
|
@ -300,6 +318,7 @@ class PlanProductLine(ModelSQL, ModelView):
|
|||
__name__ = 'product.cost.plan.product_line'
|
||||
|
||||
name = fields.Char('Name', required=True)
|
||||
sequence = fields.Integer('Sequence')
|
||||
plan = fields.Many2One('product.cost.plan', 'Plan', required=True,
|
||||
ondelete='CASCADE')
|
||||
product = fields.Many2One('product.product', 'Product',
|
||||
|
@ -332,6 +351,16 @@ class PlanProductLine(ModelSQL, ModelView):
|
|||
'quantity', 'cost_price', 'uom', 'product'], digits=(16, 4)),
|
||||
'on_change_with_total')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(PlanProductLine, cls).__setup__()
|
||||
cls._order.insert(0, ('sequence', 'ASC'))
|
||||
|
||||
@staticmethod
|
||||
def order_sequence(tables):
|
||||
table, _ = tables[None]
|
||||
return [table.sequence == None, table.sequence]
|
||||
|
||||
def on_change_product(self):
|
||||
res = {}
|
||||
if self.product:
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
<newline/>
|
||||
<label name="product"/>
|
||||
<field name="product"/>
|
||||
<label name="uom"/>
|
||||
<field name="uom"/>
|
||||
<label name="bom"/>
|
||||
<field name="bom"/>
|
||||
<notebook colspan="6">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<tree string="Product Cost Plan Product Line" editable="bottom">
|
||||
<tree string="Product Cost Plan Product Line" editable="bottom" sequence="sequence">
|
||||
<field name="plan"/>
|
||||
<field name="name"/>
|
||||
<field name="product"/>
|
||||
|
|
Loading…
Reference in New Issue