diff --git a/models/sale.py b/models/sale.py index ee54afb395cc6ea1dfef8f33041b1777d371d84a..5f8ed9a979c18084c598e0c361854d9e609c1d87 100644 --- a/models/sale.py +++ b/models/sale.py @@ -63,15 +63,6 @@ class FinacoopSaleOrder(models.Model): if self.lettre_coop: self.content_html = self.lettre_coop.body_html - @api.multi - def action_confirm(self): - if self.lettre_coop_sale: - if not self.pdf_lettre_signe: - return False - res = super(FinacoopSaleOrder, self).action_confirm() - return True - - @api.multi def validate_lc(self): self.filtered(lambda s: s.state == 'draft').write({'state': 'lc_ok'}) diff --git a/views/sale_views.xml b/views/sale_views.xml index cebae38d98dfb0c88122049cf10a42fbda0ea5e5..bb8e04d767e12656d5a3416ee841d0269735dcbf 100644 --- a/views/sale_views.xml +++ b/views/sale_views.xml @@ -9,7 +9,10 @@ <field name="arch" type="xml"> <!-- HEADER FORM --> <xpath expr="//button[@name='action_cancel']" position="after"> - <button name="%(finacoop_wizard_lettre_preview)d" string="Prévisualiser lettre de Coop" type="action" attrs="{'invisible': [('state', '!=', 'draft')]}" /> + <button name="%(finacoop_wizard_lettre_preview)d" + string="Prévisualiser lettre de Coop" + type="action" + attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('lettre_coop', '=', False)]}" /> </xpath> <!-- Senb by email --> <xpath expr="//button[@name='action_quotation_send']" position="attributes"> @@ -21,14 +24,24 @@ <attribute name="class"></attribute> </xpath> <xpath expr="//button[@name='print_quotation']" position="before"> - <button name="validate_lc" string="Valider LC" type="object" states="draft" class="btn-primary"/> + <button name="validate_lc" + string="Valider LC" + type="object" + attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('lettre_coop', '=', False)]}" + class="btn-primary"/> </xpath> <xpath expr="//button[@name='action_confirm'][2]" position="attributes"> <attribute name="states">lc_ok</attribute> </xpath> <!-- Print LC --> <xpath expr="//button[@name='print_quotation'][2]" position="before"> - <button name="%(report_finacoop_lettre_coop_pdf)d" string="Imprimer LC" icon="fa-print" type="action" states="lc_ok,sent,sale" class="btn-primary"/> + <button + name="%(report_finacoop_lettre_coop_pdf)d" + string="Imprimer LC" + icon="fa-print" + type="action" + attrs="{'invisible': ['|', ('state', 'not in', ('lc_ok', 'sent', 'sale')), ('lettre_coop', '=', False)]}" + class="btn-primary"/> </xpath> <!-- Cancel --> <xpath expr="//button[@name='action_cancel']" position="attributes"> @@ -47,12 +60,12 @@ <field name="contact" attrs="{'invisible': [('partner_id', '=', False)]}" domain="[('parent_id', '=', partner_id)]" /> </xpath> <xpath expr="//field[@name='payment_term_id']" position="after"> - <field name="lettre_coop" required="1" /> - <field name="millesime" required="1" /> + <field name="lettre_coop" /> + <field name="millesime" attrs="{'required': [('lettre_coop', '!=', False)]}"/> <field name="tarifs_horaires" attrs="{'readonly': [('state', '!=', 'draft')]}"/> </xpath> <xpath expr="//notebook" position="before"> - <div> + <div attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('lettre_coop', '=', False)]}"> <label for="pdf_lettre_signe"/>: <field name="pdf_filename" invisible="1"/><field widget="binary" name="pdf_lettre_signe" filename="pdf_filename"/> </div> </xpath> @@ -83,7 +96,7 @@ </group> </group> </page> - <page string="Lettre de Coop" name="lc_preview"> + <page string="Lettre de Coop" name="lc_preview" attrs="{'invisible': [('lettre_coop', '=', False)]}"> <group> <group> <field name="annexe1"/>