diff --git a/models/account_invoice.py b/models/account_invoice.py index 8f960f7e2402fd42b1f031c03283f521e980a7bd..57e14ac2f1524a17954d885cc79690c4b48ed2fc 100755 --- a/models/account_invoice.py +++ b/models/account_invoice.py @@ -50,6 +50,29 @@ class ScopAccountInvoice(models.Model): ('4', '4')], default='4', required=True) + is_sdd = fields.Boolean( + 'Au prélèvement', + compute='compute_is_sdd', + search='_search_is_sdd') + + # ------------------------------------------------------ + # Computed field + # ------------------------------------------------------ + @api.multi + def compute_is_sdd(self): + sdd_id = self.env.ref( + 'account_banking_sepa_direct_debit.sepa_direct_debit').id + for invoice in self: + if invoice.payment_mode_id and invoice.payment_mode_id.payment_method_id.id == sdd_id: + invoice.is_sdd = True + else: + invoice.is_sdd = False + + @api.multi + def _search_is_sdd(self, operator, value): + recs = self.search([]).filtered(lambda x: x.is_sdd is True) + if recs: + return [('id', 'in', [x.id for x in recs])] # ------------------------------------------------------ # Override Parent diff --git a/views/account_invoice.xml b/views/account_invoice.xml index fa5e50cd7609245ac4926dd1fec2e1e22c123a54..73a5f56a413297381ae9facd8706b0c142ca2c5d 100644 --- a/views/account_invoice.xml +++ b/views/account_invoice.xml @@ -64,7 +64,9 @@ <xpath expr="//field[@name='origin']" position="attributes"> <attribute name="invisible">True</attribute> </xpath> - + <xpath expr="//field[@name='state']" position="after"> + <field name="is_sdd" invisible="1"/> + </xpath> </field> </record> @@ -88,6 +90,7 @@ <filter name="2_quarter" string="Sur 2 trimestres" domain="[('nb_quarter', '=', '2')]"/> <filter name="1_quarter" string="Sur 1 trimestre" domain="[('nb_quarter', '=', '1')]"/> <separator/> + <filter name="is_sdd" string="Cotisation au prélèvement" domain="[('is_sdd', '=', True)]"/> <field name="partner_id" operator="child_of"/> <field name="number" string="Invoice" context="{'active_test': False}" filter_domain="['|','|','|', ('number','ilike',self), ('origin','ilike',self), ('reference', 'ilike', self), ('partner_id', 'child_of', self)]"/> <!-- <field name="user_id" string="Salesperson" domain="[('share','=', False)]"/>-->