Add cost field in timesheet lines
This commit is contained in:
parent
8092fc807d
commit
50bbdd2255
|
@ -3,9 +3,11 @@
|
|||
# the full copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
from .work import *
|
||||
from .line import *
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Work,
|
||||
Line,
|
||||
module='timesheet_cost_revenue', type_='model')
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
# This file is part timesheet_cost_revenue module for Tryton.
|
||||
# The COPYRIGHT file at the top level of this repository contains
|
||||
# the full copyright notices and license terms.
|
||||
from decimal import Decimal
|
||||
|
||||
from trytond.model import fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
__all__ = ['Line']
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class Line():
|
||||
__name__ = 'timesheet.line'
|
||||
cost = fields.Function(fields.Numeric('Cost',
|
||||
digits=(16, Eval('currency_digits', 2)),
|
||||
depends=['currency_digits']), 'on_change_with_cost')
|
||||
currency_digits = fields.Function(fields.Integer('Currency Digits'),
|
||||
'on_change_with_currency_digits')
|
||||
|
||||
@fields.depends('employee', 'date', 'hours', 'work')
|
||||
def on_change_with_cost(self, name=None):
|
||||
if self.employee and self.hours and self.work:
|
||||
return self.compute_cost()
|
||||
return Decimal(0)
|
||||
|
||||
@fields.depends('work')
|
||||
def on_change_with_currency_digits(self, name=None):
|
||||
if self.work:
|
||||
return self.work.currency_digits
|
||||
return 2
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part timesheet_cost_revenue module for 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="line_view_form">
|
||||
<field name="model">timesheet.line</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit" ref="timesheet.line_view_form"/>
|
||||
<field name="name">line_form</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="line_view_tree">
|
||||
<field name="model">timesheet.line</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="inherit" ref="timesheet.line_view_tree"/>
|
||||
<field name="name">line_tree</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
|
@ -2,6 +2,14 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:timesheet.line,cost:"
|
||||
msgid "Cost"
|
||||
msgstr "Cost"
|
||||
|
||||
msgctxt "field:timesheet.line,currency_digits:"
|
||||
msgid "Currency Digits"
|
||||
msgstr "Decimals de moneda"
|
||||
|
||||
msgctxt "field:timesheet.work,list_price:"
|
||||
msgid "List Price"
|
||||
msgstr "Preu de venda"
|
||||
|
@ -18,6 +26,10 @@ msgctxt "view:product.template:"
|
|||
msgid "Review"
|
||||
msgstr "Revisió"
|
||||
|
||||
msgctxt "view:timesheet.line:"
|
||||
msgid "Cost"
|
||||
msgstr "Cost"
|
||||
|
||||
msgctxt "view:timesheet.work:"
|
||||
msgid "Cost & Revenue"
|
||||
msgstr "Costos & Ingressos"
|
||||
|
|
|
@ -2,6 +2,14 @@
|
|||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=utf-8\n"
|
||||
|
||||
msgctxt "field:timesheet.line,cost:"
|
||||
msgid "Cost"
|
||||
msgstr "Coste"
|
||||
|
||||
msgctxt "field:timesheet.line,currency_digits:"
|
||||
msgid "Currency Digits"
|
||||
msgstr "Decimales de moneda"
|
||||
|
||||
msgctxt "field:timesheet.work,list_price:"
|
||||
msgid "List Price"
|
||||
msgstr "Precio de venta"
|
||||
|
@ -18,6 +26,10 @@ msgctxt "view:product.template:"
|
|||
msgid "Review"
|
||||
msgstr "Revisión"
|
||||
|
||||
msgctxt "view:timesheet.line:"
|
||||
msgid "Cost"
|
||||
msgstr "Coste"
|
||||
|
||||
msgctxt "view:timesheet.work:"
|
||||
msgid "Cost & Revenue"
|
||||
msgstr "Costes & Ingresos"
|
||||
|
|
|
@ -5,3 +5,4 @@ depends:
|
|||
timesheet_cost
|
||||
xml:
|
||||
work.xml
|
||||
line.xml
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part production_cost_timesheet module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name="description"]" position="after">
|
||||
<label name="cost"/>
|
||||
<field name="cost"/>
|
||||
</xpath>
|
||||
</data>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part production_cost_timesheet module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/tree/field[@name="description"]" position="after">
|
||||
<field name="cost" sum="Cost"/>
|
||||
</xpath>
|
||||
</data>
|
|
@ -2,8 +2,7 @@
|
|||
<!-- This file is part production_cost_timesheet module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/form/field[@name="company"]"
|
||||
position="after">
|
||||
<xpath expr="/form/field[@name="company"]" position="after">
|
||||
<separator string="Cost & Revenue" colspan="4" id="cost_revenue"/>
|
||||
<label name="product"/>
|
||||
<field name="product"/>
|
||||
|
|
Loading…
Reference in New Issue