From c3cf05af3ef9a5055981594163fcfbd71c9be811 Mon Sep 17 00:00:00 2001 From: Mansi Gandhi Date: Tue, 13 Dec 2016 12:03:09 +0530 Subject: [PATCH] [IMP] sale,account: Move pro-forma to sales and make it a quote report Purpose ======= we use to make proforma invoice to get payment before the creation of the real invoice. In the current odoo, the proforma state is too late. Because you have to confirm the SO to generate the draft invoice and so the proforma. But, if you do that, you have generated a subscription or a delivery order in the mean time. A proforma is actually a quote. In old ERP they used to make proforma to send a quote and don't generate invoice number. Specification ============= - Remove everything related to Proforma from accounting - Remove the configuration of pro-forma from account setting - Invoice form, remove "Pro-froma" button, stage, report title - Add proforma configuration option in sales setting under "Quotation and Sales" section - In quote/sale, add Pro-forma under Print - A pro-forma is a quote, but the title of the report is Pro-Forma and not Quotation - button (secondary) on quotation form "SEND PRO-FORMA" to send proforma by mail attached with related report. - button - mail template - when preparing a quotation this button is visible but if even one invoice this should be invisible (as confirming SO doesn't generate invoice currently) --- .../data/email_template_data_invoice.xml | 2 +- addons/account/models/account_invoice.py | 16 ++++---------- .../models/account_journal_dashboard.py | 2 +- addons/account/models/res_config.py | 3 --- .../account/report/account_invoice_report.py | 2 -- .../report/account_invoice_report_view.xml | 3 +-- addons/account/security/account_security.xml | 6 ----- .../tests/test_account_customer_invoice.py | 6 ----- addons/account/views/account_invoice_view.xml | 22 ++++++++----------- .../views/account_journal_dashboard_view.xml | 2 +- addons/account/views/report_invoice.xml | 1 - addons/account/views/res_config_view.xml | 11 ---------- .../account/wizard/account_invoice_refund.py | 4 ++-- .../account/wizard/account_invoice_state.py | 4 ++-- addons/account_cancel/views/account_views.xml | 4 ++-- addons/membership/models/membership.py | 2 +- addons/membership/models/partner.py | 2 +- .../report_intrastat_invoice_template.xml | 1 - addons/sale/data/mail_template_data.xml | 9 ++++++-- addons/sale/models/sale.py | 8 +++---- addons/sale/models/sale_config_settings.py | 2 ++ addons/sale/report/sale_report.py | 14 ++++++++++++ addons/sale/report/sale_report.xml | 12 ++++++++++ addons/sale/report/sale_report_templates.xml | 9 ++++++-- addons/sale/security/sale_security.xml | 5 +++++ .../sale/views/sale_config_settings_views.xml | 11 ++++++++++ addons/sale/views/sale_views.xml | 2 ++ 27 files changed, 89 insertions(+), 76 deletions(-) diff --git a/addons/account/data/email_template_data_invoice.xml b/addons/account/data/email_template_data_invoice.xml index 94a9be1cb77..e1442d6b421 100644 --- a/addons/account/data/email_template_data_invoice.xml +++ b/addons/account/data/email_template_data_invoice.xml @@ -29,7 +29,7 @@ % if object.number: invoice ${object.number} % else: -pro-forma invoice +invoice % endif % if object.origin: (with reference: ${object.origin}) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 7c18865b558..58c2b72ceb1 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -221,8 +221,6 @@ class AccountInvoice(models.Model): state = fields.Selection([ ('draft','Draft'), - ('proforma', 'Pro-forma'), - ('proforma2', 'Pro-forma'), ('open', 'Open'), ('paid', 'Paid'), ('cancel', 'Cancelled'), @@ -549,18 +547,12 @@ class AccountInvoice(models.Model): attachment.unlink() return True - @api.multi - def action_invoice_proforma2(self): - if self.filtered(lambda inv: inv.state != 'draft'): - raise UserError(_("Invoice must be a draft in order to set it to Pro-forma.")) - return self.write({'state': 'proforma2'}) - @api.multi def action_invoice_open(self): # lots of duplicate calls to action_invoice_open, so we remove those already open to_open_invoices = self.filtered(lambda inv: inv.state != 'open') - if to_open_invoices.filtered(lambda inv: inv.state not in ['proforma2', 'draft']): - raise UserError(_("Invoice must be in draft or Pro-forma state in order to validate it.")) + if to_open_invoices.filtered(lambda inv: inv.state != 'draft'): + raise UserError(_("Invoice must be in draft state in order to validate it.")) to_open_invoices.action_date_assign() to_open_invoices.action_move_create() return to_open_invoices.invoice_validate() @@ -583,8 +575,8 @@ class AccountInvoice(models.Model): @api.multi def action_invoice_cancel(self): - if self.filtered(lambda inv: inv.state not in ['proforma2', 'draft', 'open']): - raise UserError(_("Invoice must be in draft, Pro-forma or open state in order to be cancelled.")) + if self.filtered(lambda inv: inv.state not in ['draft', 'open']): + raise UserError(_("Invoice must be in draft or open state in order to be cancelled.")) return self.action_cancel() @api.multi diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py index d70eaa807bb..3498b71fe7f 100644 --- a/addons/account/models/account_journal_dashboard.py +++ b/addons/account/models/account_journal_dashboard.py @@ -175,7 +175,7 @@ class account_journal(models.Model): number_waiting = 0 for result in query_results: cur = self.env['res.currency'].browse(result.get('currency')) - if result.get('state') in ['draft', 'proforma', 'proforma2']: + if result.get('state') == 'draft': number_draft += 1 sum_draft += cur.compute(result.get('amount_total'), currency) elif result.get('state') == 'open': diff --git a/addons/account/models/res_config.py b/addons/account/models/res_config.py index dea258f4350..cf94197d1a7 100644 --- a/addons/account/models/res_config.py +++ b/addons/account/models/res_config.py @@ -32,9 +32,6 @@ class AccountConfigSettings(models.TransientModel): module_account_deferred_revenue = fields.Boolean(string="Revenue Recognition") module_account_budget = fields.Boolean(string='Budget Management') module_account_reports = fields.Boolean("Dynamic Reports") - group_proforma_invoices = fields.Boolean(string='Allow pro-forma invoices', - implied_group='account.group_proforma_invoices', - help="Allows you to put invoices in pro-forma state.") module_account_reports_followup = fields.Boolean("Enable payment followup management") default_sale_tax_id = fields.Many2one('account.tax', string="Default Sale Tax", default_model="account.config.settings", company_dependent=True, oldname="default_sale_tax") diff --git a/addons/account/report/account_invoice_report.py b/addons/account/report/account_invoice_report.py index f75fffea723..cf9b5738a47 100644 --- a/addons/account/report/account_invoice_report.py +++ b/addons/account/report/account_invoice_report.py @@ -55,8 +55,6 @@ class AccountInvoiceReport(models.Model): ], readonly=True) state = fields.Selection([ ('draft', 'Draft'), - ('proforma', 'Pro-forma'), - ('proforma2', 'Pro-forma'), ('open', 'Open'), ('paid', 'Paid'), ('cancel', 'Cancelled') diff --git a/addons/account/report/account_invoice_report_view.xml b/addons/account/report/account_invoice_report_view.xml index 5ceb73ecce1..a7cb1c560b9 100644 --- a/addons/account/report/account_invoice_report_view.xml +++ b/addons/account/report/account_invoice_report_view.xml @@ -72,8 +72,7 @@ - - + diff --git a/addons/account/security/account_security.xml b/addons/account/security/account_security.xml index 846a86724b2..d80c2797177 100644 --- a/addons/account/security/account_security.xml +++ b/addons/account/security/account_security.xml @@ -25,12 +25,6 @@ - - - Pro-forma Invoices - - - A warning can be set on a partner (Account) diff --git a/addons/account/tests/test_account_customer_invoice.py b/addons/account/tests/test_account_customer_invoice.py index 0c559892644..201d973673c 100644 --- a/addons/account/tests/test_account_customer_invoice.py +++ b/addons/account/tests/test_account_customer_invoice.py @@ -70,12 +70,6 @@ class TestAccountCustomerInvoice(AccountTestUsers): # I check that Initially customer invoice is in the "Draft" state self.assertEquals(self.account_invoice_customer0.state, 'draft') - # I change the state of invoice to "Proforma2" by clicking PRO-FORMA button - self.account_invoice_customer0.action_invoice_proforma2() - - # I check that the invoice state is now "Proforma2" - self.assertEquals(self.account_invoice_customer0.state, 'proforma2') - # I check that there is no move attached to the invoice self.assertEquals(len(self.account_invoice_customer0.move_id), 0) diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml index 7154cb65c66..ce0079f032e 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -173,7 +173,7 @@
-
@@ -217,10 +217,10 @@
-
@@ -348,16 +348,14 @@
-
@@ -366,8 +364,7 @@ -