Add sale reporting per promotion
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
* Add sale reporting per promotion
|
||||||
* Add relate from promotions to sales
|
* Add relate from promotions to sales
|
||||||
|
|
||||||
Version 7.2.0 - 2024-04-29
|
Version 7.2.0 - 2024-04-29
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
|
|
||||||
from . import sale
|
from . import sale, sale_reporting
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
@@ -13,4 +13,5 @@ def register():
|
|||||||
sale.Promotion_ProductCategory,
|
sale.Promotion_ProductCategory,
|
||||||
sale.Sale,
|
sale.Sale,
|
||||||
sale.Line,
|
sale.Line,
|
||||||
|
sale_reporting.Promotion,
|
||||||
module='sale_promotion', type_='model')
|
module='sale_promotion', type_='model')
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
|
||||||
|
from sql import Literal
|
||||||
|
|
||||||
|
from trytond.model import ModelView, fields
|
||||||
|
from trytond.modules.sale.sale_reporting import Abstract
|
||||||
|
|
||||||
|
|
||||||
|
class Promotion(Abstract, ModelView):
|
||||||
|
"Sale Reporting per Promotion"
|
||||||
|
__name__ = 'sale.reporting.promotion'
|
||||||
|
|
||||||
|
promotion = fields.Many2One('sale.promotion', "Promotion")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _sale_line_columns(cls, line, sale):
|
||||||
|
return super()._sale_line_columns(line, sale) + [
|
||||||
|
line.promotion.as_('promotion')]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _pos_sale_line_columns(cls, line, point, sale, currency):
|
||||||
|
try:
|
||||||
|
columns = super()._pos_sale_line_columns(
|
||||||
|
line, point, sale, currency)
|
||||||
|
except AttributeError:
|
||||||
|
columns = []
|
||||||
|
return columns + [Literal(None).as_('promotion')]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _columns(cls, tables, withs):
|
||||||
|
line = tables['line']
|
||||||
|
return super()._columns(tables, withs) + [line.promotion]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _group_by(cls, tables, withs):
|
||||||
|
line = tables['line']
|
||||||
|
return super()._group_by(tables, withs) + [line.promotion]
|
||||||
|
|
||||||
|
def get_rec_name(self, name):
|
||||||
|
return self.promotion.rec_name if self.promotion else None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def search_rec_name(cls, name, clause):
|
||||||
|
return [('promotion.rec_name', *clause[1:])]
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?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="sale_reporting_promotion_view_list">
|
||||||
|
<field name="model">sale.reporting.promotion</field>
|
||||||
|
<field name="type" eval="None"/>
|
||||||
|
<field name="inherit" ref="sale.reporting_main_view_list"/>
|
||||||
|
<field name="name">sale_reporting_promotion_list</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.action.act_window" id="act_sale_reporting_promotion">
|
||||||
|
<field name="name">Sales per Promotion</field>
|
||||||
|
<field name="res_model">sale.reporting.promotion</field>
|
||||||
|
<field name="context_model">sale.reporting.context</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.view" id="act_sale_reporting_promotion_view1">
|
||||||
|
<field name="sequence" eval="10"/>
|
||||||
|
<field name="view" ref="sale_reporting_promotion_view_list"/>
|
||||||
|
<field name="act_window" ref="act_sale_reporting_promotion"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.keyword" id="act_sale_reporting_promotion_keyword1">
|
||||||
|
<field name="keyword">tree_open</field>
|
||||||
|
<field name="model" ref="sale.menu_reporting_sale"/>
|
||||||
|
<field name="action" ref="act_sale_reporting_promotion"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.rule.group" id="rule_group_reporting_promotion_companies">
|
||||||
|
<field name="name">User in companies</field>
|
||||||
|
<field name="model">sale.reporting.promotion</field>
|
||||||
|
<field name="global_p" eval="True"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.rule" id="rule_reporting_promotion_companies">
|
||||||
|
<field name="domain" eval="[('company', 'in', Eval('companies', []))]" pyson="1"/>
|
||||||
|
<field name="rule_group" ref="rule_group_reporting_promotion_companies"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</tryton>
|
||||||
@@ -41,13 +41,16 @@ else:
|
|||||||
download_url = 'http://downloads.tryton.org/%s.%s/' % (
|
download_url = 'http://downloads.tryton.org/%s.%s/' % (
|
||||||
major_version, minor_version)
|
major_version, minor_version)
|
||||||
|
|
||||||
requires = ['simpleeval']
|
requires = ['simpleeval', 'python-sql']
|
||||||
for dep in info.get('depends', []):
|
for dep in info.get('depends', []):
|
||||||
if not re.match(r'(ir|res)(\W|$)', dep):
|
if not re.match(r'(ir|res)(\W|$)', dep):
|
||||||
requires.append(get_require_version('trytond_%s' % dep))
|
requires.append(get_require_version('trytond_%s' % dep))
|
||||||
requires.append(get_require_version('trytond'))
|
requires.append(get_require_version('trytond'))
|
||||||
|
|
||||||
tests_require = [get_require_version('proteus')]
|
tests_require = [
|
||||||
|
get_require_version('proteus'),
|
||||||
|
get_require_version('trytond_sale_point'),
|
||||||
|
]
|
||||||
|
|
||||||
setup(name=name,
|
setup(name=name,
|
||||||
version=version,
|
version=version,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from trytond.tests.test_tryton import ModuleTestCase
|
|||||||
class SalePromotionTestCase(CompanyTestMixin, ModuleTestCase):
|
class SalePromotionTestCase(CompanyTestMixin, ModuleTestCase):
|
||||||
'Test Sale Promotion module'
|
'Test Sale Promotion module'
|
||||||
module = 'sale_promotion'
|
module = 'sale_promotion'
|
||||||
|
extras = ['sale_point']
|
||||||
|
|
||||||
|
|
||||||
del ModuleTestCase
|
del ModuleTestCase
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ depends:
|
|||||||
res
|
res
|
||||||
sale
|
sale
|
||||||
sale_price_list
|
sale_price_list
|
||||||
|
extras_depend:
|
||||||
|
sale_point
|
||||||
xml:
|
xml:
|
||||||
sale.xml
|
sale.xml
|
||||||
|
sale_reporting.xml
|
||||||
message.xml
|
message.xml
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?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="//field[@name='number']" position="before">
|
||||||
|
<field name="promotion" expand="1"/>
|
||||||
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='revenue_trend']" position="replace"></xpath>
|
||||||
|
</data>
|
||||||
Reference in New Issue
Block a user