Pricing linked

This commit is contained in:
2026-06-16 15:35:12 +02:00
parent 38af948374
commit 8eba0cd066
4 changed files with 19 additions and 7 deletions

View File

@@ -44,7 +44,9 @@ class Fee(ModelSQL,ModelView):
shipment_out = fields.Many2One('stock.shipment.out', ondelete='CASCADE')
shipment_internal = fields.Many2One(
'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)
type = fields.Selection([
('budgeted', 'Budgeted'),
@@ -60,17 +62,14 @@ class Fee(ModelSQL,ModelView):
enable_linked_currency = fields.Boolean("Linked currencies")
linked_price = fields.Numeric("Linked Price", digits='unit', states={
'invisible': ~Eval('enable_linked_currency'),
'required': Eval('enable_linked_currency'),
}, depends=['enable_linked_currency'])
linked_currency = fields.Many2One('currency.linked', "Linked Currency",
states={
'invisible': ~Eval('enable_linked_currency'),
'required': Eval('enable_linked_currency'),
}, depends=['enable_linked_currency'])
linked_unit = fields.Many2One('product.uom', "Linked Unit",
states={
'invisible': ~Eval('enable_linked_currency'),
'required': Eval('enable_linked_currency'),
}, depends=['enable_linked_currency'])
mode = fields.Selection([
('lumpsum', 'Lump sum'),

View File

@@ -2537,9 +2537,20 @@ class PurchaseTradeTestCase(ModuleTestCase):
self.assertEqual(fee.on_change_with_quantity(), Decimal('25'))
def test_fee_currency_is_required(self):
'fee currency is required for every fee mode'
self.assertTrue(fee_module.Fee.currency.required)
def test_fee_currency_is_conditionally_required_for_linked_currency(self):
'fee currency does not block linked currency draft saves'
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):
'fee non-cog amount is zero before any accounting move line exists'

View File

@@ -8,6 +8,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="mode"/>
<field name="unit"/>
<field name="auto_calculation" width="60"/>
<field name="enable_linked_currency" width="60"/>
<field name="price"/>
<field name="currency"/>
<field name="weight_type"/>

View File

@@ -8,6 +8,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="mode"/>
<field name="unit"/>
<field name="auto_calculation" width="60"/>
<field name="enable_linked_currency" width="60"/>
<field name="price"/>
<field name="currency"/>
<field name="weight_type"/>