[IMP] commission_simple: validation from list view

This commit is contained in:
Alexis de Lattre
2025-10-10 14:21:31 +00:00
committed by Florian da Costa
parent b02ff59054
commit 988d63fac0
3 changed files with 9 additions and 2 deletions

View File

@@ -63,7 +63,7 @@ class CommissionResult(models.Model):
return super().unlink()
def draft2done(self):
self.write({'state': 'done'})
self.filtered(lambda x: x.state == 'draft').write({'state': 'done'})
def backtodraft(self):
self.write({'state': 'draft'})

View File

@@ -72,6 +72,13 @@
<field name="model">commission.result</field>
<field name="arch" type="xml">
<tree decoration-info="state == 'draft'">
<header>
<button
name="draft2done"
type="object"
string="Validate"
/>
</header>
<field name="date_range_id" optional="show"/>
<field name="date_start" optional="hide"/>
<field name="date_end" optional="hide"/>

View File

@@ -15,7 +15,7 @@ class CommissionResult(models.Model):
def draft2done(self):
for result in self:
if result.assign_type == 'agent':
if result.state == "draft" and result.assign_type == 'agent':
if not result.purchase_id:
vals = result._prepare_purchase_order()
po = self.env['purchase.order'].create(vals)