[FIX] field in attrs and compute count field based on folios count

This commit is contained in:
Dario Lodeiros
2019-04-08 18:31:18 +02:00
parent b62cad0287
commit 682dd59531
2 changed files with 7 additions and 7 deletions

View File

@@ -12,10 +12,6 @@ class FolioAdvancePaymentInv(models.TransientModel):
_name = "folio.advance.payment.inv"
_description = "Folios Advance Payment Invoice"
@api.model
def _count(self):
return len(self._context.get('active_ids', []))
@api.model
def _get_advance_payment_method(self):
return 'all'
@@ -69,7 +65,7 @@ class FolioAdvancePaymentInv(models.TransientModel):
auto_invoice = fields.Boolean('Auto Payment Invoice',
default=True,
help='Automatic validation and link payment to invoice')
count = fields.Integer(default=_count, string='# of Orders')
count = fields.Integer(compute='_count', store=True, string='# of Orders')
folio_ids = fields.Many2many("hotel.folio", string="Folios",
help="Folios grouped",
default=_get_default_folio)
@@ -98,6 +94,11 @@ class FolioAdvancePaymentInv(models.TransientModel):
help="Taxes used for deposits",
default=_default_deposit_taxes_id)
@api.depends('folio_ids')
def _count(self):
for record in self:
record.update({'count': len(self.folio_ids)})
@api.onchange('advance_payment_method')
def onchange_advance_payment_method(self):
if self.advance_payment_method == 'percentage':

View File

@@ -37,8 +37,7 @@
context="{'search_default_partner_invoice_id': partner_invoice_id}"
>
<tree string="Folios" editable="bottom"
decoration-danger="partner_invoice_id != parent.partner_invoice_id"
attrs="{'invisible': [('advance_payment_method', 'in', ('fixed','percentage'))]}">
decoration-danger="partner_invoice_id != parent.partner_invoice_id">
<field name="partner_invoice_id" />
<field name="name" />
<field name="state" />