Add direct cost
This commit is contained in:
parent
7a49d72ca5
commit
69b49ba7d7
11
__init__.py
11
__init__.py
|
@ -1,11 +1,11 @@
|
||||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
from . import production
|
import production
|
||||||
from . import account
|
import account
|
||||||
from . import stock
|
import stock
|
||||||
from . import ir
|
import ir
|
||||||
from . import bom
|
import bom
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
|
@ -16,6 +16,7 @@ def register():
|
||||||
production.ProductionDetailedStart,
|
production.ProductionDetailedStart,
|
||||||
ir.Cron,
|
ir.Cron,
|
||||||
bom.BOM,
|
bom.BOM,
|
||||||
|
bom.BOMDirectCost,
|
||||||
module='production_accounting', type_='model')
|
module='production_accounting', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
production.ProductionDetailed,
|
production.ProductionDetailed,
|
||||||
|
|
26
bom.py
26
bom.py
|
@ -1,15 +1,18 @@
|
||||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
from trytond.pool import Pool, PoolMeta
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from datetime import datetime, date
|
||||||
|
|
||||||
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.modules.product import round_price
|
from trytond.modules.product import round_price
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from datetime import datetime, date
|
from trytond.model import fields, ModelSQL, ModelView
|
||||||
|
|
||||||
|
|
||||||
class BOM(metaclass=PoolMeta):
|
class BOM(metaclass=PoolMeta):
|
||||||
"Bill of Material"
|
|
||||||
__name__ = 'production.bom'
|
__name__ = 'production.bom'
|
||||||
|
direct_costs = fields.One2Many('production.bom.direct_cost',
|
||||||
|
'bom', 'Direct Costs')
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def calc_cost_ldm(cls):
|
def calc_cost_ldm(cls):
|
||||||
|
@ -52,3 +55,20 @@ class BOM(metaclass=PoolMeta):
|
||||||
cost += (Decimal(str(quantity)) * cost_price)
|
cost += (Decimal(str(quantity)) * cost_price)
|
||||||
|
|
||||||
return round_price(cost)
|
return round_price(cost)
|
||||||
|
|
||||||
|
|
||||||
|
class BOMDirectCost(ModelSQL, ModelView):
|
||||||
|
"BOMDirectCost"
|
||||||
|
__name__ = "production.bom.direct_cost"
|
||||||
|
bom = fields.Many2One('production.bom', 'BOM', required=True,
|
||||||
|
ondelete='CASCADE')
|
||||||
|
product = fields.Many2One('product.product', 'Product', required=True,
|
||||||
|
domain=[('type', '!=', 'active')])
|
||||||
|
uom = fields.Many2One('product.uom', 'UoM')
|
||||||
|
quantity = fields.Float('Quantity', required=True, digits=(16,2))
|
||||||
|
notes = fields.Char('Notes')
|
||||||
|
|
||||||
|
@fields.depends('product', 'uom')
|
||||||
|
def on_change_with_uom(self, name=None):
|
||||||
|
if self.product:
|
||||||
|
return self.product.default_uom.id
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
this repository contains the full copyright notices and license terms. -->
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
<record model="ir.ui.view" id="bom_view_form">
|
||||||
|
<field name="model">production.bom</field>
|
||||||
|
<field name="inherit" ref="production.bom_view_form"/>
|
||||||
|
<field name="name">bom_form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="bom_direct_cost_view_form">
|
||||||
|
<field name="model">production.bom.direct_cost</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">bom_direct_cost_form</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.ui.view" id="bom_direct_cost_view_tree">
|
||||||
|
<field name="model">production.bom.direct_cost</field>
|
||||||
|
<field name="type">tree</field>
|
||||||
|
<field name="name">bom_direct_cost_tree</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</tryton>
|
|
@ -1,5 +1,5 @@
|
||||||
[tryton]
|
[tryton]
|
||||||
version=6.0.2
|
version=6.0.3
|
||||||
depends:
|
depends:
|
||||||
party
|
party
|
||||||
company
|
company
|
||||||
|
@ -11,3 +11,4 @@ xml:
|
||||||
message.xml
|
message.xml
|
||||||
production.xml
|
production.xml
|
||||||
product.xml
|
product.xml
|
||||||
|
bom.xml
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<form>
|
||||||
|
<label name="product"/>
|
||||||
|
<field name="product"/>
|
||||||
|
<label name="uom"/>
|
||||||
|
<field name="uom"/>
|
||||||
|
<label name="quantity"/>
|
||||||
|
<field name="quantity"/>
|
||||||
|
<label name="notes"/>
|
||||||
|
<field name="notes"/>
|
||||||
|
</form>
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<tree>
|
||||||
|
<field name="product"/>
|
||||||
|
<field name="uom"/>
|
||||||
|
<field name="quantity"/>
|
||||||
|
<field name="notes"/>
|
||||||
|
</tree>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
this repository contains the full copyright notices and license terms. -->
|
||||||
|
<data>
|
||||||
|
<xpath expr="/form/notebook/page[@id='lines']" position="after">
|
||||||
|
<page string="Related Costs" id="page_related_costs">
|
||||||
|
<field name="direct_costs" colspan="4"/>
|
||||||
|
</page>
|
||||||
|
</xpath>
|
||||||
|
</data>
|
|
@ -22,5 +22,4 @@ this repository contains the full copyright notices and license terms. -->
|
||||||
<label name="effective_start_date"/>
|
<label name="effective_start_date"/>
|
||||||
<field name="effective_start_date"/>
|
<field name="effective_start_date"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|
Loading…
Reference in New Issue