[IMP] commission_simple: validation from list view
This commit is contained in:
committed by
Florian da Costa
parent
b02ff59054
commit
988d63fac0
@@ -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'})
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user