2 Commits

Author SHA1 Message Date
Stéphan Sainléger
cb302a30b4 [IMP] event_generate_quotation_from_registration: block field edition
of event.registration.financier if the quotation is done.
2025-06-05 09:05:45 +02:00
Stéphan Sainléger
fcfb571112 [IMP] event_generate_quotation_from_registration: prevent edition attempts of done sale orders 2025-06-05 08:42:31 +02:00
3 changed files with 11 additions and 5 deletions

View File

@@ -36,8 +36,9 @@ class EventRegistration(models.Model):
financier.quotation_id = sale_order financier.quotation_id = sale_order
else: else:
order_lines = self.env['sale.order.line'].search([ order_lines = self.env['sale.order.line'].search([
('order_id','=',financier.quotation_id.id), ('order_id','=',financier.quotation_id.id),
('product_id','=',financier.get_product_id()) ('product_id','=',financier.get_product_id()),
('state', '!=', 'done'),
]) ])
if order_lines: if order_lines:
order_lines[0].price_unit = financier.amount order_lines[0].price_unit = financier.amount

View File

@@ -17,6 +17,10 @@ class EventRegistrationFinancier(models.Model):
financier_id = fields.Many2one('res.partner', string="Financeur", required=True) financier_id = fields.Many2one('res.partner', string="Financeur", required=True)
terms = fields.Char('Modalités') terms = fields.Char('Modalités')
amount = fields.Monetary('Montant', currency_field="company_currency_id") amount = fields.Monetary('Montant', currency_field="company_currency_id")
state = fields.Selection(
related='quotation_id.state',
string="Order Status",
copy=False, store=True, precompute=True)
def get_product_id(self): def get_product_id(self):

View File

@@ -10,9 +10,10 @@
<group name="quotation" string="Financement" colspan="1"> <group name="quotation" string="Financement" colspan="1">
<field name="financier_ids" nolabel="1" colspan="2"> <field name="financier_ids" nolabel="1" colspan="2">
<tree editable="bottom"> <tree editable="bottom">
<field name="financier_id" /> <field name="state" invisible="1"/>
<field name="amount" /> <field name="financier_id" attrs="{'readonly': [('state', 'in', ['done', 'cancel'])]}"/>
<field name="terms" /> <field name="amount" attrs="{'readonly': [('state', 'in', ['done', 'cancel'])]}" />
<field name="terms" />
<field name="quotation_id" readonly="True" /> <field name="quotation_id" readonly="True" />
</tree> </tree>
</field> </field>