Added fields cases_quantity and ul_quantity to the sale reporting.
This commit refs #6004
This commit is contained in:
parent
6c5e8b6a58
commit
f6cbe416af
|
@ -4,6 +4,7 @@ from trytond.pool import Pool
|
|||
from .sale import SaleLine, Sale
|
||||
from .unit_load import UnitLoad
|
||||
from .cost import CostType, CostTemplate, CostLineSale, CostSale
|
||||
from . import sale_reporting
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -11,8 +12,8 @@ def register():
|
|||
Sale,
|
||||
SaleLine,
|
||||
UnitLoad,
|
||||
sale_reporting.Product,
|
||||
module='sale_unit_load', type_='model')
|
||||
|
||||
Pool.register(
|
||||
CostType,
|
||||
CostTemplate,
|
||||
|
|
11
locale/es.po
11
locale/es.po
|
@ -60,4 +60,13 @@ msgstr "Bultos"
|
|||
|
||||
msgctxt "selection:sale.cost,distribution_method:"
|
||||
msgid "ULs quantity"
|
||||
msgstr "UdCs"
|
||||
msgstr "UdCs"
|
||||
|
||||
msgctxt "field:sale.reporting.product,cases_quantity:"
|
||||
msgid "Cases"
|
||||
msgstr "Bultos"
|
||||
|
||||
msgctxt "field:sale.reporting.product,ul_quantity:"
|
||||
msgid "ULs"
|
||||
msgstr "UdCs"
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
# The COPYRIGHT file at the top level of this repository contains the full
|
||||
# copyright notices and license terms.
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.model import fields
|
||||
from trytond.pyson import Eval
|
||||
from sql.aggregate import Sum
|
||||
from sql.conditionals import Coalesce
|
||||
|
||||
__all__ = ['Product']
|
||||
|
||||
|
||||
class Product:
|
||||
__name__ = 'sale.reporting.product'
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
cases_quantity = fields.Float('Cases',
|
||||
digits=(16, Eval('cases_digits', 2)),
|
||||
depends=['cases_digits'])
|
||||
ul_quantity = fields.Float('ULs', digits=(16, 0))
|
||||
cases_digits = fields.Function(fields.Integer('Cases Digits'),
|
||||
'get_cases_digits')
|
||||
|
||||
def get_cases_digits(self, name):
|
||||
pool = Pool()
|
||||
Modeldata = pool.get('ir.model.data')
|
||||
Uom = pool.get('product.uom')
|
||||
return Uom(Modeldata.get_id('product', 'uom_unit')).digits
|
||||
|
||||
@classmethod
|
||||
def _columns(cls, tables):
|
||||
line = tables['line']
|
||||
return super(Product, cls)._columns(tables) + [
|
||||
Sum(Coalesce(line.ul_cases_quantity, 0) *
|
||||
Coalesce(line.ul_quantity, 0)).as_('cases_quantity'),
|
||||
Sum(Coalesce(line.ul_quantity, 0)).as_('ul_quantity')
|
||||
]
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<!-- Product -->
|
||||
<record model="ir.ui.view" id="reporting_product_view_list">
|
||||
<field name="model">sale.reporting.product</field>
|
||||
<field name="inherit" ref="sale.reporting_product_view_list"/>
|
||||
<field name="name">reporting_product_list</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
|
@ -11,3 +11,4 @@ extras_depend:
|
|||
|
||||
xml:
|
||||
sale.xml
|
||||
sale_reporting.xml
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||
copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="/tree/field[@name='revenue']" position="after">
|
||||
<field name="cases_quantity"/>
|
||||
<field name="ul_quantity"/>
|
||||
</xpath>
|
||||
</data>
|
Loading…
Reference in New Issue