02.04.26
This commit is contained in:
@@ -3,9 +3,10 @@
|
||||
|
||||
from trytond.pool import Pool
|
||||
|
||||
from . import (
|
||||
account,
|
||||
purchase,
|
||||
from . import (
|
||||
account,
|
||||
configuration,
|
||||
purchase,
|
||||
sale,
|
||||
global_reporting,
|
||||
stock,
|
||||
@@ -54,9 +55,10 @@ def register():
|
||||
incoming.ImportSwift,
|
||||
lc.LCMT700,
|
||||
lc.LCMessage,
|
||||
lc.CreateLCStart,
|
||||
global_reporting.GRConfiguration,
|
||||
module='purchase_trade', type_='model')
|
||||
lc.CreateLCStart,
|
||||
global_reporting.GRConfiguration,
|
||||
configuration.Configuration,
|
||||
module='purchase_trade', type_='model')
|
||||
Pool.register(
|
||||
incoming.ImportSwift,
|
||||
incoming.PrepareDocuments,
|
||||
|
||||
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>
|
||||
@@ -1026,10 +1026,18 @@ class QualityAnalysis(ModelSQL,ModelView):
|
||||
))
|
||||
return " | ".join(filter(None, values))
|
||||
|
||||
class Line(metaclass=PoolMeta):
|
||||
__name__ = 'purchase.line'
|
||||
|
||||
quantity_theorical = fields.Numeric("Contractual Qt", digits='unit', readonly=False)
|
||||
class Line(metaclass=PoolMeta):
|
||||
__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)
|
||||
price_type = fields.Selection([
|
||||
('cash', 'Cash Price'),
|
||||
('priced', 'Priced'),
|
||||
@@ -1099,7 +1107,8 @@ class Line(metaclass=PoolMeta):
|
||||
'required': Eval('enable_linked_currency'),
|
||||
}, depends=['enable_linked_currency'])
|
||||
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(
|
||||
'product.attribute', 'Attributes',
|
||||
@@ -1137,9 +1146,16 @@ class Line(metaclass=PoolMeta):
|
||||
('umpire', 'Umpire'),
|
||||
], "Type")
|
||||
|
||||
@classmethod
|
||||
def default_finished(cls):
|
||||
return False
|
||||
@classmethod
|
||||
def default_finished(cls):
|
||||
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')
|
||||
|
||||
@@ -746,10 +746,18 @@ class PriceComposition(metaclass=PoolMeta):
|
||||
|
||||
sale_line = fields.Many2One('sale.line',"Sale line")
|
||||
|
||||
class SaleLine(metaclass=PoolMeta):
|
||||
__name__ = 'sale.line'
|
||||
|
||||
del_period = fields.Many2One('product.month',"Delivery Period")
|
||||
class SaleLine(metaclass=PoolMeta):
|
||||
__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")
|
||||
lots = fields.One2Many('lot.lot','sale_line',"Lots",readonly=True)
|
||||
fees = fields.One2Many('fee.fee', 'sale_line', 'Fees')
|
||||
quantity_theorical = fields.Numeric("Th. quantity", digits='unit', readonly=True)
|
||||
|
||||
@@ -156,6 +156,34 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
sale.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):
|
||||
'sale report helpers aggregate quantity, price lines and shipment periods'
|
||||
Sale = Pool().get('sale.sale')
|
||||
|
||||
@@ -10,12 +10,13 @@ depends:
|
||||
lot
|
||||
document_incoming
|
||||
incoterm
|
||||
xml:
|
||||
purchase.xml
|
||||
sale.xml
|
||||
lot.xml
|
||||
pricing.xml
|
||||
stock.xml
|
||||
xml:
|
||||
purchase.xml
|
||||
sale.xml
|
||||
lot.xml
|
||||
pricing.xml
|
||||
configuration.xml
|
||||
stock.xml
|
||||
workflow.xml
|
||||
lc.xml
|
||||
optional.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>
|
||||
@@ -93,11 +93,15 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<page string="Pricing dates" col="4" id="pricing_date">
|
||||
<field name="price_pricing" />
|
||||
</page>
|
||||
<page string="Summary" col="4" id="summary">
|
||||
<field name="price_summary" />
|
||||
</page>
|
||||
</notebook>
|
||||
</page>
|
||||
<page string="Summary" col="4" id="summary">
|
||||
<field name="price_summary" />
|
||||
</page>
|
||||
<page string="Report" col="4" id="report">
|
||||
<label name="pricing_rule" />
|
||||
<field name="pricing_rule" />
|
||||
</page>
|
||||
</notebook>
|
||||
</page>
|
||||
<page string="Estimated dates" col="4" id="estimated">
|
||||
<field name="estimated_date" />
|
||||
</page>
|
||||
|
||||
Reference in New Issue
Block a user