diff --git a/models/account_move.py b/models/account_move.py index c03816accbe9851b7da69673af2376b6bb97b18c..054fb0fbd426c49709d9ada6f6e810095db58788 100644 --- a/models/account_move.py +++ b/models/account_move.py @@ -17,7 +17,7 @@ class AccountMove(models.Model): # Fields declaration # ------------------------------------------------------ is_fee = fields.Boolean( - string="Redevance", + string="Est une redevance", related="journal_id.is_fee", readonly=True, store=True, @@ -39,6 +39,7 @@ class AccountMove(models.Model): compute="_compute_fee_state", store=True, ) + end_fee_reason = fields.Char(string="Raison du non renouvellement") # ------------------------------------------------------ # Computed fields / Search Fields @@ -77,6 +78,7 @@ class AccountMove(models.Model): """ Create new invoice with start and end fee dates """ + self.ensure_one() new_start_fee = self.end_fee + relativedelta(days=1) new_end_fee = self.end_fee + relativedelta(years=1) next_fee_id = self.copy( @@ -98,6 +100,12 @@ class AccountMove(models.Model): "target": "current", } + def action_not_renewed(self): + self.ensure_one() + if self.next_fee_id: + self.next_fee_id.unlink() + self.fee_state = "not_renewed" + # ------------------------------------------------------ # Business methods # ------------------------------------------------------ diff --git a/views/account_move.xml b/views/account_move.xml index b8b06ef78d8045e972c8b9118a8af7e317ab1854..af0f8576537ae3df4ebce7224c5593c4175ff3c7 100644 --- a/views/account_move.xml +++ b/views/account_move.xml @@ -42,16 +42,16 @@ <group> <field name="is_fee" - attrs="{'readonly': [('move_type', '=', 'posted')]}" + attrs="{'readonly': [('state', '=', 'posted')]}" groups="base.group_no_one" /> <field name="start_fee" - attrs="{'invisible': [('is_fee', '=', False)], 'required': [('is_fee', '=', True)], 'readonly': [('move_type', '=', 'posted')]}" + attrs="{'invisible': [('is_fee', '=', False)], 'required': [('is_fee', '=', True)], 'readonly': [('state', '=', 'posted')]}" /> <field name="end_fee" - attrs="{'invisible': [('is_fee', '=', False)], 'required': [('is_fee', '=', True)], 'readonly': [('move_type', '=', 'posted')]}" + attrs="{'invisible': [('is_fee', '=', False)], 'required': [('is_fee', '=', True)], 'readonly': [('state', '=', 'posted')]}" /> </group> <group> @@ -64,6 +64,19 @@ name="fee_state" attrs="{'invisible': [('state', '!=', 'posted')]}" /> + <div colspan="2"> + <button + name="action_not_renewed" + type="object" + string="Non renouvellement" + attrs="{'invisible': [('fee_state', 'not in', ['to_renew', 'renewing'])]}" + confirm="Valider le non renouvellement de cette redevance ?" + /> + </div> + <field + name="end_fee_reason" + attrs="{'invisible': [('fee_state', '!=', 'not_renewed')]}" + /> </group> </group> </xpath> @@ -119,7 +132,21 @@ </record> <!-- Pivot view --> + <record id="afac_fee_account_invoice_view_pivot" model="ir.ui.view"> + <field name="name">account.invoice.pivot</field> + <field name="model">account.move</field> + <field name="arch" type="xml"> + <pivot string="Factures"> + <field name="is_fee" type="col" /> + <field name="invoice_date" type="row" /> + <field name="amount_total_signed" type="measure" /> + </pivot> + </field> + </record> - <!-- Action view --> + <!-- Action view : add pivot view --> + <record id="account.action_move_out_invoice_type" model="ir.actions.act_window"> + <field name="view_mode">tree,kanban,pivot,form</field> + </record> </data> </odoo>