02.04.26
This commit is contained in:
@@ -5,6 +5,7 @@ from trytond.pool import Pool
|
|||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
account,
|
account,
|
||||||
|
configuration,
|
||||||
purchase,
|
purchase,
|
||||||
sale,
|
sale,
|
||||||
global_reporting,
|
global_reporting,
|
||||||
@@ -56,6 +57,7 @@ def register():
|
|||||||
lc.LCMessage,
|
lc.LCMessage,
|
||||||
lc.CreateLCStart,
|
lc.CreateLCStart,
|
||||||
global_reporting.GRConfiguration,
|
global_reporting.GRConfiguration,
|
||||||
|
configuration.Configuration,
|
||||||
module='purchase_trade', type_='model')
|
module='purchase_trade', type_='model')
|
||||||
Pool.register(
|
Pool.register(
|
||||||
incoming.ImportSwift,
|
incoming.ImportSwift,
|
||||||
|
|||||||
8
modules/purchase_trade/configuration.py
Normal file
8
modules/purchase_trade/configuration.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from trytond.model import ModelSingleton, ModelSQL, ModelView, fields
|
||||||
|
|
||||||
|
|
||||||
|
class Configuration(ModelSingleton, ModelSQL, ModelView):
|
||||||
|
"Purchase Trade Configuration"
|
||||||
|
__name__ = 'purchase_trade.configuration'
|
||||||
|
|
||||||
|
pricing_rule = fields.Text("Pricing Rule")
|
||||||
27
modules/purchase_trade/configuration.xml
Normal file
27
modules/purchase_trade/configuration.xml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
<record model="ir.ui.view" id="purchase_trade_configuration_view_form">
|
||||||
|
<field name="model">purchase_trade.configuration</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">configuration_form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.action.act_window" id="act_purchase_trade_configuration_form">
|
||||||
|
<field name="name">Pricing Configuration</field>
|
||||||
|
<field name="res_model">purchase_trade.configuration</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.view" id="act_purchase_trade_configuration_form_view1">
|
||||||
|
<field name="sequence" eval="10"/>
|
||||||
|
<field name="view" ref="purchase_trade_configuration_view_form"/>
|
||||||
|
<field name="act_window" ref="act_purchase_trade_configuration_form"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
name="Configuration"
|
||||||
|
parent="menu_mtm"
|
||||||
|
action="act_purchase_trade_configuration_form"
|
||||||
|
sequence="20"
|
||||||
|
id="menu_purchase_trade_configuration"
|
||||||
|
icon="tryton-settings"/>
|
||||||
|
</data>
|
||||||
|
</tryton>
|
||||||
@@ -1029,6 +1029,14 @@ class QualityAnalysis(ModelSQL,ModelView):
|
|||||||
class Line(metaclass=PoolMeta):
|
class Line(metaclass=PoolMeta):
|
||||||
__name__ = 'purchase.line'
|
__name__ = 'purchase.line'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def default_pricing_rule(cls):
|
||||||
|
Configuration = Pool().get('purchase_trade.configuration')
|
||||||
|
configurations = Configuration.search([], limit=1)
|
||||||
|
if configurations:
|
||||||
|
return configurations[0].pricing_rule or ''
|
||||||
|
return ''
|
||||||
|
|
||||||
quantity_theorical = fields.Numeric("Contractual Qt", digits='unit', readonly=False)
|
quantity_theorical = fields.Numeric("Contractual Qt", digits='unit', readonly=False)
|
||||||
price_type = fields.Selection([
|
price_type = fields.Selection([
|
||||||
('cash', 'Cash Price'),
|
('cash', 'Cash Price'),
|
||||||
@@ -1100,6 +1108,7 @@ class Line(metaclass=PoolMeta):
|
|||||||
}, depends=['enable_linked_currency'])
|
}, depends=['enable_linked_currency'])
|
||||||
premium = fields.Numeric("Premium/Discount",digits='unit')
|
premium = fields.Numeric("Premium/Discount",digits='unit')
|
||||||
fee_ = fields.Many2One('fee.fee',"Fee")
|
fee_ = fields.Many2One('fee.fee',"Fee")
|
||||||
|
pricing_rule = fields.Text("Pricing description")
|
||||||
|
|
||||||
attributes = fields.Dict(
|
attributes = fields.Dict(
|
||||||
'product.attribute', 'Attributes',
|
'product.attribute', 'Attributes',
|
||||||
@@ -1141,6 +1150,13 @@ class Line(metaclass=PoolMeta):
|
|||||||
def default_finished(cls):
|
def default_finished(cls):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@property
|
||||||
|
def report_fixing_rule(self):
|
||||||
|
pricing_rule = ''
|
||||||
|
if self.pricing_rule:
|
||||||
|
pricing_rule = self.pricing_rule
|
||||||
|
return pricing_rule
|
||||||
|
|
||||||
|
|
||||||
@fields.depends('product')
|
@fields.depends('product')
|
||||||
def on_change_with_attribute_set(self, name=None):
|
def on_change_with_attribute_set(self, name=None):
|
||||||
|
|||||||
@@ -749,6 +749,14 @@ class PriceComposition(metaclass=PoolMeta):
|
|||||||
class SaleLine(metaclass=PoolMeta):
|
class SaleLine(metaclass=PoolMeta):
|
||||||
__name__ = 'sale.line'
|
__name__ = 'sale.line'
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def default_pricing_rule(cls):
|
||||||
|
Configuration = Pool().get('purchase_trade.configuration')
|
||||||
|
configurations = Configuration.search([], limit=1)
|
||||||
|
if configurations:
|
||||||
|
return configurations[0].pricing_rule or ''
|
||||||
|
return ''
|
||||||
|
|
||||||
del_period = fields.Many2One('product.month',"Delivery Period")
|
del_period = fields.Many2One('product.month',"Delivery Period")
|
||||||
lots = fields.One2Many('lot.lot','sale_line',"Lots",readonly=True)
|
lots = fields.One2Many('lot.lot','sale_line',"Lots",readonly=True)
|
||||||
fees = fields.One2Many('fee.fee', 'sale_line', 'Fees')
|
fees = fields.One2Many('fee.fee', 'sale_line', 'Fees')
|
||||||
|
|||||||
@@ -156,6 +156,34 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
|||||||
sale.crop.name = 'Main Crop'
|
sale.crop.name = 'Main Crop'
|
||||||
self.assertEqual(sale.report_crop_name, 'Main Crop')
|
self.assertEqual(sale.report_crop_name, 'Main Crop')
|
||||||
|
|
||||||
|
def test_sale_line_default_pricing_rule_comes_from_configuration(self):
|
||||||
|
'sale line pricing_rule defaults to the purchase_trade singleton value'
|
||||||
|
SaleLine = Pool().get('sale.line')
|
||||||
|
config = Mock(pricing_rule='Default pricing rule')
|
||||||
|
configuration_model = Mock()
|
||||||
|
configuration_model.search.return_value = [config]
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
'trytond.modules.purchase_trade.sale.Pool'
|
||||||
|
) as PoolMock:
|
||||||
|
PoolMock.return_value.get.return_value = configuration_model
|
||||||
|
self.assertEqual(
|
||||||
|
SaleLine.default_pricing_rule(), 'Default pricing rule')
|
||||||
|
|
||||||
|
def test_purchase_line_default_pricing_rule_comes_from_configuration(self):
|
||||||
|
'purchase line pricing_rule defaults to the purchase_trade singleton value'
|
||||||
|
PurchaseLine = Pool().get('purchase.line')
|
||||||
|
config = Mock(pricing_rule='Default pricing rule')
|
||||||
|
configuration_model = Mock()
|
||||||
|
configuration_model.search.return_value = [config]
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
'trytond.modules.purchase_trade.purchase.Pool'
|
||||||
|
) as PoolMock:
|
||||||
|
PoolMock.return_value.get.return_value = configuration_model
|
||||||
|
self.assertEqual(
|
||||||
|
PurchaseLine.default_pricing_rule(), 'Default pricing rule')
|
||||||
|
|
||||||
def test_sale_report_multi_line_helpers_aggregate_all_lines(self):
|
def test_sale_report_multi_line_helpers_aggregate_all_lines(self):
|
||||||
'sale report helpers aggregate quantity, price lines and shipment periods'
|
'sale report helpers aggregate quantity, price lines and shipment periods'
|
||||||
Sale = Pool().get('sale.sale')
|
Sale = Pool().get('sale.sale')
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ xml:
|
|||||||
sale.xml
|
sale.xml
|
||||||
lot.xml
|
lot.xml
|
||||||
pricing.xml
|
pricing.xml
|
||||||
|
configuration.xml
|
||||||
stock.xml
|
stock.xml
|
||||||
workflow.xml
|
workflow.xml
|
||||||
lc.xml
|
lc.xml
|
||||||
|
|||||||
5
modules/purchase_trade/view/configuration_form.xml
Normal file
5
modules/purchase_trade/view/configuration_form.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<form col="4">
|
||||||
|
<label name="pricing_rule"/>
|
||||||
|
<field name="pricing_rule" colspan="3"/>
|
||||||
|
</form>
|
||||||
@@ -96,6 +96,10 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<page string="Summary" col="4" id="summary">
|
<page string="Summary" col="4" id="summary">
|
||||||
<field name="price_summary" />
|
<field name="price_summary" />
|
||||||
</page>
|
</page>
|
||||||
|
<page string="Report" col="4" id="report">
|
||||||
|
<label name="pricing_rule" />
|
||||||
|
<field name="pricing_rule" />
|
||||||
|
</page>
|
||||||
</notebook>
|
</notebook>
|
||||||
</page>
|
</page>
|
||||||
<page string="Estimated dates" col="4" id="estimated">
|
<page string="Estimated dates" col="4" id="estimated">
|
||||||
|
|||||||
Reference in New Issue
Block a user