diff --git a/models/scop_cotisations_idf.py b/models/scop_cotisations_idf.py index 699379fc27852d02e75d5fbcde55f9d7a63701e2..b790ac63537074ca3b3a8177c6f877acb7de38f2 100644 --- a/models/scop_cotisations_idf.py +++ b/models/scop_cotisations_idf.py @@ -28,6 +28,7 @@ class ScopCotisationsIDF(models.Model): type = fields.Selection([ ('inv', 'Cotisation'), ('refund', 'Avoir'), + ('reject', 'Rejet'), ('pay', 'Paiment')], string='Type', ) lettrage = fields.Char('Lettrage') @@ -70,11 +71,6 @@ class ScopCotisationsIDF(models.Model): # ------------------------------------------------------ # Computed fields # ------------------------------------------------------ - # @api.multi - # def _compute_currency(self): - # for r in self: - # r.currency_id = r.env - @api.depends('payment_or_refund_ids', 'debit', 'payment_or_refund_ids.debit', 'payment_or_refund_ids.debit') @api.multi diff --git a/models/scop_invoice_idf.py b/models/scop_invoice_idf.py index f48a732d4e44eb769247bf2badb499780f017d41..87e32073c59681a55d8e1fa1d8ff3105b060c407 100644 --- a/models/scop_invoice_idf.py +++ b/models/scop_invoice_idf.py @@ -28,6 +28,7 @@ class ScopinvoiceIDF(models.Model): type = fields.Selection([ ('inv', 'Facture'), ('refund', 'Avoir'), + ('reject', 'Rejet'), ('pay', 'Paiment')], string='Type',) lettrage = fields.Char('Lettrage') diff --git a/views/scop_cotisations_idf.xml b/views/scop_cotisations_idf.xml index e1d8c325aac6757bb756a60d90619cab4676a4de..0c6b83a64e563fe7feba139db7314d55a3d3559d 100644 --- a/views/scop_cotisations_idf.xml +++ b/views/scop_cotisations_idf.xml @@ -73,6 +73,7 @@ <field name="currency_id" invisible="1"/> <field name="credit" widget="monetary" string="Montant" attrs="{'invisible': [('type', '=', 'inv')]}"/> <field name="debit" widget="monetary" string="Montant" attrs="{'invisible': [('type', '!=', 'inv')]}"/> + <field name="debit" widget="monetary" string="Montant rejeté" attrs="{'invisible': [('type', '!=', 'reject')]}"/> <field name="amount_residual" widget="monetary" attrs="{'invisible': [('type', '!=', 'inv')]}"/> <field name="invoice_id" @@ -157,6 +158,7 @@ <filter name="group_by_partner_id" string="Adhérent" context="{'group_by':'partner_id'}"/> <separator/> <filter string="Date écriture" name="groupby_writing_date" context="{'group_by':'writing_date'}"/> + <filter string="Type" name="groupby_type" context="{'group_by':'type'}"/> </group> </search> </field> diff --git a/views/scop_invoice_idf.xml b/views/scop_invoice_idf.xml index 2074f36125ad732a35bb289b4ec1bd1136e6c57e..74180251c1f75e91d0f925081f0150e31f9b4862 100644 --- a/views/scop_invoice_idf.xml +++ b/views/scop_invoice_idf.xml @@ -69,6 +69,7 @@ <field name="currency_id" invisible="1"/> <field name="credit" widget="monetary" string="Montant" attrs="{'invisible': [('type', '=', 'inv')]}"/> <field name="debit" widget="monetary" string="Montant" attrs="{'invisible': [('type', '!=', 'inv')]}"/> + <field name="debit" widget="monetary" string="Montant rejeté" attrs="{'invisible': [('type', '!=', 'reject')]}"/> <field name="amount_residual" widget="monetary" attrs="{'invisible': [('type', '!=', 'inv')]}"/> <field name="invoice_id" @@ -149,6 +150,7 @@ <filter name="group_by_partner_id" string="Adhérent" context="{'group_by':'partner_id'}"/> <separator/> <filter string="Date écriture" name="groupby_writing_date" context="{'group_by':'writing_date'}"/> + <filter string="Type" name="groupby_type" context="{'group_by':'type'}"/> </group> </search> </field> diff --git a/wizard/scop_invoice_idf_wizard.py b/wizard/scop_invoice_idf_wizard.py index 07a6e0c011b945ace6312dab15df77af1aaebcb0..f1b4b6678fdb61ae9d36743ff0b71635462e6f7c 100644 --- a/wizard/scop_invoice_idf_wizard.py +++ b/wizard/scop_invoice_idf_wizard.py @@ -126,31 +126,37 @@ class ScopImportIDFWizard(models.TransientModel): else: debit = int(row['Débit euro']) credit = int(row['Crédit euro']) - if journal == "VE" and debit > 0: - line_type = "inv" - elif journal == "BFC" and debit == 0: - line_type = "pay" + if debit > 0 and credit > 0: + logs += "<li> Ligne " + str( + line) + ": Montants incorrects</li>" else: - line_type = "refund" - - lettrage = row['Lettrage N'] - year = int(row['Année']) - - values = { - 'company_id': company_id.id, - 'partner_id': partner_id.id, - 'journal': journal, - 'writing_date': writing_date, - 'name': libelle, - 'year': year, - 'type': line_type, - 'lettrage': lettrage, - 'debit': debit, - 'credit': credit, - } - new_line = self.env[model].create(values) - success += 1 - new_lines_years.add(new_line.year) + if journal == "VE" and debit > 0: + line_type = "inv" + elif journal == "BFC" and credit > 0: + line_type = "pay" + elif journal == "BFC" and debit > 0: + line_type = "reject" + else: + line_type = "refund" + + lettrage = row['Lettrage N'] + year = int(row['Année']) + + values = { + 'company_id': company_id.id, + 'partner_id': partner_id.id, + 'journal': journal, + 'writing_date': writing_date, + 'name': libelle, + 'year': year, + 'type': line_type, + 'lettrage': lettrage, + 'debit': debit, + 'credit': credit, + } + new_line = self.env[model].create(values) + success += 1 + new_lines_years.add(new_line.year) logs += "</ul>" new_log.write({