Pricing linked
This commit is contained in:
@@ -44,7 +44,9 @@ class Fee(ModelSQL,ModelView):
|
|||||||
shipment_out = fields.Many2One('stock.shipment.out', ondelete='CASCADE')
|
shipment_out = fields.Many2One('stock.shipment.out', ondelete='CASCADE')
|
||||||
shipment_internal = fields.Many2One(
|
shipment_internal = fields.Many2One(
|
||||||
'stock.shipment.internal', ondelete='CASCADE')
|
'stock.shipment.internal', ondelete='CASCADE')
|
||||||
currency = fields.Many2One('currency.currency',"Currency", required=True)
|
currency = fields.Many2One('currency.currency',"Currency", states={
|
||||||
|
'required': ~Eval('enable_linked_currency'),
|
||||||
|
}, depends=['enable_linked_currency'])
|
||||||
supplier = fields.Many2One('party.party',"Supplier", required=True)
|
supplier = fields.Many2One('party.party',"Supplier", required=True)
|
||||||
type = fields.Selection([
|
type = fields.Selection([
|
||||||
('budgeted', 'Budgeted'),
|
('budgeted', 'Budgeted'),
|
||||||
@@ -60,17 +62,14 @@ class Fee(ModelSQL,ModelView):
|
|||||||
enable_linked_currency = fields.Boolean("Linked currencies")
|
enable_linked_currency = fields.Boolean("Linked currencies")
|
||||||
linked_price = fields.Numeric("Linked Price", digits='unit', states={
|
linked_price = fields.Numeric("Linked Price", digits='unit', states={
|
||||||
'invisible': ~Eval('enable_linked_currency'),
|
'invisible': ~Eval('enable_linked_currency'),
|
||||||
'required': Eval('enable_linked_currency'),
|
|
||||||
}, depends=['enable_linked_currency'])
|
}, depends=['enable_linked_currency'])
|
||||||
linked_currency = fields.Many2One('currency.linked', "Linked Currency",
|
linked_currency = fields.Many2One('currency.linked', "Linked Currency",
|
||||||
states={
|
states={
|
||||||
'invisible': ~Eval('enable_linked_currency'),
|
'invisible': ~Eval('enable_linked_currency'),
|
||||||
'required': Eval('enable_linked_currency'),
|
|
||||||
}, depends=['enable_linked_currency'])
|
}, depends=['enable_linked_currency'])
|
||||||
linked_unit = fields.Many2One('product.uom', "Linked Unit",
|
linked_unit = fields.Many2One('product.uom', "Linked Unit",
|
||||||
states={
|
states={
|
||||||
'invisible': ~Eval('enable_linked_currency'),
|
'invisible': ~Eval('enable_linked_currency'),
|
||||||
'required': Eval('enable_linked_currency'),
|
|
||||||
}, depends=['enable_linked_currency'])
|
}, depends=['enable_linked_currency'])
|
||||||
mode = fields.Selection([
|
mode = fields.Selection([
|
||||||
('lumpsum', 'Lump sum'),
|
('lumpsum', 'Lump sum'),
|
||||||
|
|||||||
@@ -2537,9 +2537,20 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
|||||||
|
|
||||||
self.assertEqual(fee.on_change_with_quantity(), Decimal('25'))
|
self.assertEqual(fee.on_change_with_quantity(), Decimal('25'))
|
||||||
|
|
||||||
def test_fee_currency_is_required(self):
|
def test_fee_currency_is_conditionally_required_for_linked_currency(self):
|
||||||
'fee currency is required for every fee mode'
|
'fee currency does not block linked currency draft saves'
|
||||||
self.assertTrue(fee_module.Fee.currency.required)
|
self.assertFalse(fee_module.Fee.currency.required)
|
||||||
|
self.assertIn('required', fee_module.Fee.currency.states)
|
||||||
|
self.assertEqual(
|
||||||
|
fee_module.Fee.currency.states['required'],
|
||||||
|
~Eval('enable_linked_currency'))
|
||||||
|
|
||||||
|
for field in (
|
||||||
|
fee_module.Fee.linked_price,
|
||||||
|
fee_module.Fee.linked_currency,
|
||||||
|
fee_module.Fee.linked_unit):
|
||||||
|
self.assertFalse(field.required)
|
||||||
|
self.assertNotIn('required', field.states)
|
||||||
|
|
||||||
def test_fee_get_non_cog_returns_zero_without_move_lines(self):
|
def test_fee_get_non_cog_returns_zero_without_move_lines(self):
|
||||||
'fee non-cog amount is zero before any accounting move line exists'
|
'fee non-cog amount is zero before any accounting move line exists'
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<field name="mode"/>
|
<field name="mode"/>
|
||||||
<field name="unit"/>
|
<field name="unit"/>
|
||||||
<field name="auto_calculation" width="60"/>
|
<field name="auto_calculation" width="60"/>
|
||||||
|
<field name="enable_linked_currency" width="60"/>
|
||||||
<field name="price"/>
|
<field name="price"/>
|
||||||
<field name="currency"/>
|
<field name="currency"/>
|
||||||
<field name="weight_type"/>
|
<field name="weight_type"/>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<field name="mode"/>
|
<field name="mode"/>
|
||||||
<field name="unit"/>
|
<field name="unit"/>
|
||||||
<field name="auto_calculation" width="60"/>
|
<field name="auto_calculation" width="60"/>
|
||||||
|
<field name="enable_linked_currency" width="60"/>
|
||||||
<field name="price"/>
|
<field name="price"/>
|
||||||
<field name="currency"/>
|
<field name="currency"/>
|
||||||
<field name="weight_type"/>
|
<field name="weight_type"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user