mirror of
https://github.com/NaN-tic/trytond-product_cost_plan.git
synced 2023-12-14 03:03:11 +01:00
Add Unit Cost Price field.
This commit is contained in:
parent
19a54b4866
commit
50fcb5eb74
10
plan.py
10
plan.py
|
@ -20,7 +20,7 @@ class Plan(Workflow, ModelSQL, ModelView):
|
||||||
}, depends=['state', 'product'],
|
}, depends=['state', 'product'],
|
||||||
domain=[
|
domain=[
|
||||||
('output_products', '=', Eval('product', 0)),
|
('output_products', '=', Eval('product', 0)),
|
||||||
],)
|
])
|
||||||
boms = fields.One2Many('product.cost.plan.bom_line', 'plan', 'BOMs',
|
boms = fields.One2Many('product.cost.plan.bom_line', 'plan', 'BOMs',
|
||||||
states={
|
states={
|
||||||
'readonly': Eval('state') != 'draft',
|
'readonly': Eval('state') != 'draft',
|
||||||
|
@ -37,6 +37,8 @@ class Plan(Workflow, ModelSQL, ModelView):
|
||||||
total_cost = fields.Function(fields.Numeric('Total Cost',
|
total_cost = fields.Function(fields.Numeric('Total Cost',
|
||||||
on_change_with=['product_cost']),
|
on_change_with=['product_cost']),
|
||||||
'on_change_with_total_cost')
|
'on_change_with_total_cost')
|
||||||
|
unit_cost_price = fields.Function(fields.Numeric('Unit Cost Price'),
|
||||||
|
'get_unit_cost_price')
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
('draft', 'Draft'),
|
('draft', 'Draft'),
|
||||||
('computed', 'Computed'),
|
('computed', 'Computed'),
|
||||||
|
@ -113,6 +115,12 @@ class Plan(Workflow, ModelSQL, ModelView):
|
||||||
def on_change_with_total_cost(self, name=None):
|
def on_change_with_total_cost(self, name=None):
|
||||||
return self.product_cost
|
return self.product_cost
|
||||||
|
|
||||||
|
def get_unit_cost_price(self, name):
|
||||||
|
total_cost = self.total_cost
|
||||||
|
if self.quantity and total_cost:
|
||||||
|
return total_cost / Decimal(str(self.quantity))
|
||||||
|
return Decimal('0.0')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ModelView.button
|
@ModelView.button
|
||||||
@Workflow.transition('draft')
|
@Workflow.transition('draft')
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
</notebook>
|
</notebook>
|
||||||
<label name="total_cost"/>
|
<label name="total_cost"/>
|
||||||
<field name="total_cost"/>
|
<field name="total_cost"/>
|
||||||
|
<label name="unit_cost_price"/>
|
||||||
|
<field name="unit_cost_price"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<group id="state" colspan="6">
|
<group id="state" colspan="6">
|
||||||
<label name="state"/>
|
<label name="state"/>
|
||||||
|
|
Loading…
Reference in a new issue