diff options
Diffstat (limited to 'addons')
21 files changed, 97 insertions, 161 deletions
diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py index 3be3a3bcccd..477655ac2b6 100644 --- a/addons/account/__openerp__.py +++ b/addons/account/__openerp__.py @@ -35,7 +35,6 @@ You could use this simplified accounting in case you work with an (external) acc 'views/account_end_fy.xml', 'views/account_invoice_view.xml', 'data/invoice_action_data.xml', - 'views/account_invoice_workflow.xml', 'views/partner_view.xml', 'views/product_view.xml', 'views/account_analytic_view.xml', diff --git a/addons/account/demo/account_invoice_demo.yml b/addons/account/demo/account_invoice_demo.yml index 52f16f3240d..a925aefa6dd 100644 --- a/addons/account/demo/account_invoice_demo.yml +++ b/addons/account/demo/account_invoice_demo.yml @@ -17,7 +17,8 @@ price_unit: 280.0 quantity: 5.0 - - !workflow {model: account.invoice, action: invoice_open, ref: demo_invoice_1} + !python {model: account.invoice, id: demo_invoice_1}: + self.action_invoice_open() - !record {model: account.invoice, id: demo_invoice_2}: company_id: base.main_company @@ -32,7 +33,8 @@ price_unit: 25 quantity: 20 - - !workflow {model: account.invoice, action: invoice_open, ref: demo_invoice_2} + !python {model: account.invoice, id: demo_invoice_2}: + self.action_invoice_open() - !record {model: account.invoice, id: demo_invoice_3}: company_id: base.main_company @@ -47,7 +49,8 @@ price_unit: 15.0 quantity: 5.0 - - !workflow {model: account.invoice, action: invoice_open, ref: demo_invoice_3} + !python {model: account.invoice, id: demo_invoice_3}: + self.action_invoice_open() - Set the context for supplier bills because the 'type' field is readonly in invoice form views, so it value won't be considered by the yaml import - @@ -90,7 +93,7 @@ if account: line_vals['account_id'] = account.id self._update('account.invoice.line', 'account', line_vals, 'ceo_wages_line') - self.env['account.invoice'].browse(ref('demo_invoice_january_wages')).signal_workflow('invoice_open') + self.env['account.invoice'].browse(ref('demo_invoice_january_wages')).action_invoice_open() - !record {model: account.invoice, id: demo_invoice_equipment_purchase}: company_id: base.main_company @@ -114,7 +117,7 @@ line_vals['invoice_line_tax_ids'] = [(6, 0, [tax_id])] self._update('account.invoice.line', 'account', line_vals, 'coffee_machine_line') self.env['account.invoice'].browse(ref('demo_invoice_equipment_purchase'))._onchange_invoice_line_ids() - self.env['account.invoice'].browse(ref('demo_invoice_equipment_purchase')).signal_workflow('invoice_open') + self.env['account.invoice'].browse(ref('demo_invoice_equipment_purchase')).action_invoice_open() - !python {model: account.bank.statement.line, id: False} : | account = self.env['account.account'].search([ diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 87be174486f..bf4604cd21a 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -345,6 +345,17 @@ class AccountInvoice(models.Model): return invoice + @api.multi + def _write(self, vals): + pre_not_reconciled = self.filtered(lambda invoice: not invoice.reconciled) + pre_reconciled = self - pre_not_reconciled + res = super(AccountInvoice, self)._write(vals) + reconciled = self.filtered(lambda invoice: invoice.reconciled) + not_reconciled = self - reconciled + (reconciled & pre_reconciled).filtered(lambda invoice: invoice.state == 'open').action_invoice_paid() + (not_reconciled & pre_not_reconciled).filtered(lambda invoice: invoice.state == 'paid').action_invoice_cancel() + return res + @api.model def fields_view_get(self, view_id=None, view_type=False, toolbar=False, submenu=False): def get_view_id(xid, name): @@ -428,10 +439,6 @@ class AccountInvoice(models.Model): return self.with_context(ctx).write({'invoice_line_ids': []}) @api.multi - def confirm_paid(self): - return self.write({'state': 'paid'}) - - @api.multi def unlink(self): for invoice in self: if invoice.state not in ('draft', 'cancel'): @@ -517,11 +524,11 @@ class AccountInvoice(models.Model): self.date_due = max(line[0] for line in pterm_list) @api.multi - def action_cancel_draft(self): + def action_invoice_draft(self): + if self.filtered(lambda inv: inv.state != 'cancel'): + raise UserError(_("Invoice must be cancelled in order to reset it to draft.")) # go from canceled state to draft state self.write({'state': 'draft', 'date': False}) - self.delete_workflow() - self.create_workflow() # Delete former printed invoice try: report_invoice = self.env['report']._get_report_from_name('account.report_invoice') @@ -537,6 +544,44 @@ class AccountInvoice(models.Model): 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.")) + to_open_invoices.action_date_assign() + to_open_invoices.action_move_create() + return to_open_invoices.invoice_validate() + + @api.multi + def action_invoice_paid(self): + # lots of duplicate calls to action_invoice_paid, so we remove those already paid + to_pay_invoices = self.filtered(lambda inv: inv.state != 'paid') + if to_pay_invoices.filtered(lambda inv: inv.state != 'open'): + raise UserError(_('Invoice must be validated in order to set it to register payemnt.')) + if to_pay_invoices.filtered(lambda inv: not inv.reconciled): + raise UserError(_('You cannot pay an invoice which is partially paid. You need to reconcile payment entries first.')) + return to_pay_invoices.write({'state': 'paid'}) + + @api.multi + def action_invoice_re_open(self): + if self.filtered(lambda inv: inv.state != 'paid'): + raise UserError(_('Invoice must be paid in order to set it to register payemnt.')) + return self.write({'state': 'open'}) + + @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 or Pro-forma state in order to validate it.")) + return self.action_cancel() + + @api.multi def get_formview_id(self): """ Update form view id of action to open the invoice """ if self.type in ('in_invoice', 'in_refund'): diff --git a/addons/account/tests/test_account_customer_invoice.py b/addons/account/tests/test_account_customer_invoice.py index f24b9460cc8..0c559892644 100644 --- a/addons/account/tests/test_account_customer_invoice.py +++ b/addons/account/tests/test_account_customer_invoice.py @@ -71,7 +71,7 @@ class TestAccountCustomerInvoice(AccountTestUsers): 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.signal_workflow('invoice_proforma2') + self.account_invoice_customer0.action_invoice_proforma2() # I check that the invoice state is now "Proforma2" self.assertEquals(self.account_invoice_customer0.state, 'proforma2') @@ -80,7 +80,7 @@ class TestAccountCustomerInvoice(AccountTestUsers): self.assertEquals(len(self.account_invoice_customer0.move_id), 0) # I validate invoice by creating on - self.account_invoice_customer0.signal_workflow('invoice_open') + self.account_invoice_customer0.action_invoice_open() # I check that the invoice state is "Open" self.assertEquals(self.account_invoice_customer0.state, 'open') diff --git a/addons/account/tests/test_account_supplier_invoice.py b/addons/account/tests/test_account_supplier_invoice.py index 81a2517f2db..671cfb2dcb0 100644 --- a/addons/account/tests/test_account_supplier_invoice.py +++ b/addons/account/tests/test_account_supplier_invoice.py @@ -36,7 +36,7 @@ class TestAccountSupplierInvoice(AccountingTestCase): self.assertTrue((invoice.state == 'draft'), "Initially vendor bill state is Draft") #change the state of invoice to open by clicking Validate button - invoice.signal_workflow('invoice_open') + invoice.action_invoice_open() #I cancel the account move which is in posted state and verifies that it gives warning message with self.assertRaises(Warning): diff --git a/addons/account/tests/test_bank_statement_reconciliation.py b/addons/account/tests/test_bank_statement_reconciliation.py index 56f38fa3e69..0aee2f90811 100644 --- a/addons/account/tests/test_bank_statement_reconciliation.py +++ b/addons/account/tests/test_bank_statement_reconciliation.py @@ -66,7 +66,7 @@ class TestBankStatementReconciliation(AccountingTestCase): 'name': '.', 'account_id': self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1).id, }) - invoice.signal_workflow('invoice_open') + invoice.action_invoice_open() mv_line = None for l in invoice.move_id.line_ids: diff --git a/addons/account/tests/test_payment.py b/addons/account/tests/test_payment.py index 374ceb9c5f3..d593f4fd8e8 100644 --- a/addons/account/tests/test_payment.py +++ b/addons/account/tests/test_payment.py @@ -55,7 +55,7 @@ class TestPayment(AccountingTestCase): 'name': 'something', 'account_id': self.account_revenue.id, }) - invoice.signal_workflow('invoice_open') + invoice.action_invoice_open() return invoice def reconcile(self, liquidity_aml, amount=0.0, amount_currency=0.0, currency_id=None): diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py index ee31cf4a853..d957f7c9f5a 100644 --- a/addons/account/tests/test_reconciliation.py +++ b/addons/account/tests/test_reconciliation.py @@ -56,7 +56,7 @@ class TestReconciliation(AccountingTestCase): }) #validate invoice - invoice.signal_workflow('invoice_open') + invoice.action_invoice_open() return invoice def make_payment(self, invoice_record, bank_journal, amount=0.0, amount_currency=0.0, currency_id=None): @@ -283,7 +283,7 @@ class TestReconciliation(AccountingTestCase): }) ] }) - invoice.signal_workflow('invoice_open') + invoice.action_invoice_open() # We create a bank statement with two lines of 1.00 USD each. statement = self.acc_bank_stmt_model.create({ 'journal_id': self.bank_journal_usd_id, diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml index cfb13ee4ac4..c10018794ea 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -217,11 +217,11 @@ <field name="arch" type="xml"> <form string="Vendor Bill"> <header> - <button name="invoice_open" states="draft,proforma2" string="Validate" class="oe_highlight" groups="account.group_account_invoice"/> + <button name="action_invoice_open" type="object" states="draft,proforma2" string="Validate" class="oe_highlight" groups="account.group_account_invoice"/> <button name="%(action_account_invoice_payment)d" type="action" states="open" string="Register Payment" groups="account.group_account_invoice" class="oe_highlight"/> <button name="%(action_account_invoice_refund)d" type='action' string='Ask Refund' groups="account.group_account_invoice" attrs="{'invisible': ['|',('type', '=', 'in_refund'),('state','not in',('open','paid'))]}"/> - <button name="invoice_cancel" states="draft,proforma2" string="Cancel Bill" groups="account.group_account_invoice"/> - <button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" groups="account.group_account_invoice"/> + <button name="action_invoice_cancel" type="object" states="draft,proforma2" string="Cancel Bill" groups="account.group_account_invoice"/> + <button name="action_invoice_draft" states="cancel" string="Set to Draft" type="object" groups="account.group_account_invoice"/> <field name="state" widget="statusbar" statusbar_visible="draft,open,paid" /> </header> <div class="alert alert-info" role="alert" style="margin-bottom:0px;" attrs="{'invisible': [('has_outstanding','=',False)]}"> @@ -352,12 +352,12 @@ <button name="action_invoice_sent" type="object" string="Send by Email" attrs="{'invisible':['|',('sent','=',False), ('state', '!=', 'open')]}" groups="base.group_user"/> <button name="invoice_print" string="Print Invoice" type="object" attrs="{'invisible':['|',('sent','=',False), ('state', '!=', 'open')]}" groups="base.group_user"/> <button name="%(action_account_invoice_payment)d" type="action" states="open" string="Register Payment" groups="account.group_account_invoice" class="oe_highlight"/> - <button name="invoice_open" states="draft" string="Validate" class="oe_highlight" groups="account.group_account_user"/> - <button name="invoice_open" states="proforma2" string="Validate" groups="account.group_account_user"/> - <button name="invoice_proforma2" states="draft" string="PRO-FORMA" groups="account.group_proforma_invoices"/> - <button name="%(action_account_invoice_refund)d" type='action' string='Refund Invoice' groups="account.group_account_user" attrs="{'invisible': ['|',('type', '=', 'out_refund'), ('state', 'not in', ('open','proforma2','paid'))]}"/> - <button name="invoice_cancel" states="draft,proforma2,open" string="Cancel Invoice" groups="base.group_no_one"/> - <button name="action_cancel_draft" states="cancel" string="Reset to Draft" type="object" groups="account.group_account_user"/> + <button name="action_invoice_open" type="object" states="draft" string="Validate" class="oe_highlight" groups="base.group_account_user"/> + <button name="action_invoice_open" type="object" states="proforma2" string="Validate" groups="base.group_account_user"/> + <button name="action_invoice_proforma2" type="object" states="draft" string="PRO-FORMA" groups="account.group_proforma_invoices"/> + <button name="%(action_account_invoice_refund)d" type='action' string='Refund Invoice' groups="base.group_account_user" attrs="{'invisible': ['|',('type', '=', 'out_refund'), ('state', 'not in', ('open','proforma2','paid'))]}"/> + <button name="action_invoice_cancel" type="object" states="draft,proforma2,open" string="Cancel Invoice" groups="base.group_no_one"/> + <button name="action_invoice_draft" states="cancel" string="Reset to Draft" type="object" groups="base.group_account_user"/> <field name="state" widget="statusbar" nolabel="1" statusbar_visible="draft,open,paid"/> </header> <div class="alert alert-info" role="alert" style="margin-bottom:0px;" attrs="{'invisible': [('has_outstanding','=',False)]}"> diff --git a/addons/account/views/account_invoice_workflow.xml b/addons/account/views/account_invoice_workflow.xml deleted file mode 100644 index b5e5e3a1948..00000000000 --- a/addons/account/views/account_invoice_workflow.xml +++ /dev/null @@ -1,113 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<odoo> - <data> - - <record id="wkf" model="workflow"> - <field name="name">account.invoice.basic</field> - <field name="osv">account.invoice</field> - <field name="on_create">True</field> - </record> - - <record id="act_draft" model="workflow.activity"> - <field name="wkf_id" ref="wkf"/> - <field name="flow_start">True</field> - <field name="name">draft</field> - </record> - <record id="act_proforma2" model="workflow.activity"> - <field name="wkf_id" ref="wkf"/> - <field name="name">proforma2</field> - <field name="action">write({'state':'proforma2'})</field> - <field name="kind">function</field> - </record> - <record id="act_open" model="workflow.activity"> - <field name="wkf_id" ref="wkf"/> - <field name="name">open</field> - <field name="action">action_date_assign() -action_move_create() -invoice_validate()</field> - <field name="kind">function</field> - </record> - <record model="workflow.activity" id="act_open_test"> - <field name="wkf_id" ref="wkf"/> - <field name="name">re-open</field> - <field name="action">write({'state':'open'})</field> - <field name="kind">function</field> - </record> - <record id="act_paid" model="workflow.activity"> - <field name="wkf_id" ref="wkf"/> - <field name="name">paid</field> - <!--<field name="flow_stop">True</field>--> - <field name="action">confirm_paid()</field> - <field name="kind">function</field> - <field name="signal_send">subflow.paid</field> - </record> - <record id="act_cancel" model="workflow.activity"> - <field name="wkf_id" ref="wkf"/> - <field name="name">cancel</field> - <field name="flow_stop">True</field> - <field name="action">action_cancel() -write({'state':'cancel'})</field> - <field name="kind">function</field> - </record> - - <record id="t4" model="workflow.transition"> - <field name="act_from" ref="act_draft"/> - <field name="act_to" ref="act_open"/> - <field name="signal">invoice_open</field> - </record> - <record id="t8" model="workflow.transition"> - <field name="act_from" ref="act_open"/> - <field name="act_to" ref="act_paid"/> - <field name="trigger_model"/> - <field name="trigger_expr_id"/> - <field name="condition">reconciled</field> - </record> - <record id="t9" model="workflow.transition"> - <field name="act_from" ref="act_draft"/> - <field name="act_to" ref="act_cancel"/> - <field name="signal">invoice_cancel</field> - </record> - <record id="t12" model="workflow.transition"> - <field name="act_from" ref="act_open"/> - <field name="act_to" ref="act_cancel"/> - <field name="signal">invoice_cancel</field> - </record> - <record id="t13" model="workflow.transition"> - <field name="act_from" ref="act_paid"/> - <field name="act_to" ref="act_open_test"/> - <field name="signal"/> - <field name="condition">not reconciled</field> - </record> - <record id="t14" model="workflow.transition"> - <field name="act_from" ref="act_open_test"/> - <field name="act_to" ref="act_cancel"/> - <field name="signal">invoice_cancel</field> - </record> - - <record id="open_test_to_paid" model="workflow.transition"> - <field name="act_from" ref="act_open_test"/> - <field name="act_to" ref="act_paid"/> - <field name="trigger_model"/> - <field name="trigger_expr_id"/> - <field name="condition">reconciled</field> - </record> - - <record id="draft_to_pro2" model="workflow.transition"> - <field name="act_from" ref="account.act_draft"/> - <field name="act_to" ref="act_proforma2"/> - <field name="signal">invoice_proforma2</field> - </record> - - <record id="pro2_to_open" model="workflow.transition"> - <field name="act_from" ref="act_proforma2"/> - <field name="act_to" ref="account.act_open"/> - <field name="signal">invoice_open</field> - </record> - - <record id="pro2_to_cancel" model="workflow.transition"> - <field name="act_from" ref="act_proforma2"/> - <field name="act_to" ref="account.act_cancel"/> - <field name="signal">invoice_cancel</field> - </record> - </data> -</odoo> diff --git a/addons/account/views/account_unit_test.xml b/addons/account/views/account_unit_test.xml index 3991ce9ffcc..5a176e58ceb 100644 --- a/addons/account/views/account_unit_test.xml +++ b/addons/account/views/account_unit_test.xml @@ -44,7 +44,7 @@ <test expr="sum([l.price_subtotal for l in invoice_line_ids]) == amount_untaxed"/> </assert> - <workflow action="invoice_open" model="account.invoice" ref="test_invoice_1"/> + <function model="account.invoice" name="action_invoice_open" eval="[[ref('test_invoice_1')]]"/> <assert id="test_invoice_1" model="account.invoice" string="Test invoice 1 is now open"> <test expr="state">open</test> diff --git a/addons/account/wizard/account_invoice_refund.py b/addons/account/wizard/account_invoice_refund.py index 031999d8042..a2b6a240ad9 100644 --- a/addons/account/wizard/account_invoice_refund.py +++ b/addons/account/wizard/account_invoice_refund.py @@ -71,7 +71,7 @@ class AccountInvoiceRefund(models.TransientModel): to_reconcile_ids.setdefault(line.account_id.id, []).append(line.id) if line.reconciled: line.remove_move_reconcile() - refund.signal_workflow('invoice_open') + refund.action_invoice_open() for tmpline in refund.move_id.line_ids: if tmpline.account_id.id == inv.account_id.id: to_reconcile_lines += tmpline diff --git a/addons/account/wizard/account_invoice_state.py b/addons/account/wizard/account_invoice_state.py index e631bab8348..025df465a57 100644 --- a/addons/account/wizard/account_invoice_state.py +++ b/addons/account/wizard/account_invoice_state.py @@ -19,7 +19,7 @@ class AccountInvoiceConfirm(models.TransientModel): for record in self.env['account.invoice'].browse(active_ids): if record.state not in ('draft', 'proforma', 'proforma2'): raise UserError(_("Selected invoice(s) cannot be confirmed as they are not in 'Draft' or 'Pro-Forma' state.")) - record.signal_workflow('invoice_open') + record.action_invoice_open() return {'type': 'ir.actions.act_window_close'} @@ -40,5 +40,5 @@ class AccountInvoiceCancel(models.TransientModel): for record in self.env['account.invoice'].browse(active_ids): if record.state in ('cancel', 'paid'): raise UserError(_("Selected invoice(s) cannot be cancelled as they are already in 'Cancelled' or 'Done' state.")) - record.signal_workflow('invoice_cancel') + record.action_invoice_cancel() return {'type': 'ir.actions.act_window_close'} diff --git a/addons/account_cancel/views/account_views.xml b/addons/account_cancel/views/account_views.xml index 550cee2dd6f..41e8371efe1 100644 --- a/addons/account_cancel/views/account_views.xml +++ b/addons/account_cancel/views/account_views.xml @@ -16,8 +16,8 @@ <field name="model">account.invoice</field> <field name="inherit_id" ref="account.invoice_form"/> <field name="arch" type="xml"> - <xpath expr="//button[@name='invoice_cancel']" position="replace"> - <button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel Invoice" groups="account.group_account_invoice"/> + <xpath expr="//button[@name='action_invoice_cancel']" position="replace"> + <button name="action_invoice_cancel" type="object" states="draft,proforma2,open" string="Cancel Invoice" groups="account.group_account_invoice"/> </xpath> </field> </record> @@ -27,8 +27,8 @@ <field name="model">account.invoice</field> <field name="inherit_id" ref="account.invoice_supplier_form"/> <field name="arch" type="xml"> - <xpath expr="//button[@name='invoice_cancel']" position="replace"> - <button name="invoice_cancel" states="draft,proforma2,sale,open" string="Cancel Invoice" groups="account.group_account_invoice"/> + <xpath expr="//button[@name='action_invoice_cancel']" position="replace"> + <button name="action_invoice_cancel" type="object" states="draft,proforma2,open" string="Cancel Invoice" groups="account.group_account_invoice"/> </xpath> </field> </record> diff --git a/addons/delivery/tests/test_delivery_stock_move.py b/addons/delivery/tests/test_delivery_stock_move.py index 85646aa6575..e03043e52a3 100644 --- a/addons/delivery/tests/test_delivery_stock_move.py +++ b/addons/delivery/tests/test_delivery_stock_move.py @@ -53,11 +53,11 @@ class StockMoveInvoice(AccountingTestCase): # I confirm the invoice self.invoice = self.sale_prepaid.invoice_ids - self.invoice.signal_workflow('invoice_open') + self.invoice.action_invoice_open() # I pay the invoice. self.invoice = self.sale_prepaid.invoice_ids - self.invoice.signal_workflow('invoice_open') + self.invoice.action_invoice_open() self.journal = self.AccountJournal.search([('type', '=', 'cash'), ('company_id', '=', self.sale_prepaid.company_id.id)], limit=1) self.invoice.pay_and_reconcile(self.journal, self.invoice.amount_total) diff --git a/addons/membership/tests/test_membership.py b/addons/membership/tests/test_membership.py index 797ef5d7926..d59bc0763ba 100644 --- a/addons/membership/tests/test_membership.py +++ b/addons/membership/tests/test_membership.py @@ -44,7 +44,7 @@ class TestMembership(TestMembershipCommon): 'membership: new membership should be in waiting state') # the invoice is open -> customer goes to invoiced status - invoice.signal_workflow('invoice_open') + invoice.action_invoice_open() self.assertEqual( self.partner_1.membership_state, 'invoiced', 'membership: after opening the invoice, customer should be in invoiced status') @@ -77,6 +77,6 @@ class TestMembership(TestMembershipCommon): invoice = self.env['account.invoice'].search([('partner_id', '=', self.partner_1.id)], limit=1) # the invoice is canceled -> membership state of the customer goes to canceled - invoice.signal_workflow('invoice_cancel') + invoice.action_invoice_cancel() self.assertEqual(invoice.state, 'cancel') self.assertEqual(self.partner_1.membership_state, 'canceled') diff --git a/addons/point_of_sale/models/pos_order.py b/addons/point_of_sale/models/pos_order.py index 02f74c27b14..8bca47f7b5a 100644 --- a/addons/point_of_sale/models/pos_order.py +++ b/addons/point_of_sale/models/pos_order.py @@ -460,7 +460,9 @@ class PosOrder(models.Model): new_invoice.with_context(local_context).sudo().compute_taxes() order.sudo().write({'state': 'invoiced'}) - new_invoice.sudo().signal_workflow('validate') + # this workflow signal didn't exist on account.invoice -> should it have been 'invoice_open' ? (and now method .action_invoice_open()) + # shouldn't the created invoice be marked as paid, seing the customer paid in the POS? + # new_invoice.sudo().signal_workflow('validate') if not Invoice: return {} @@ -515,7 +517,7 @@ class PosOrder(models.Model): if to_invoice: pos_order.action_pos_order_invoice() - pos_order.invoice_id.sudo().signal_workflow('invoice_open') + pos_order.invoice_id.sudo().action_invoice_open() return order_ids def test_paid(self): diff --git a/addons/sale/models/account_invoice.py b/addons/sale/models/account_invoice.py index d195e194714..673f213609a 100644 --- a/addons/sale/models/account_invoice.py +++ b/addons/sale/models/account_invoice.py @@ -41,8 +41,8 @@ class AccountInvoice(models.Model): self.partner_shipping_id = addr and addr.get('delivery') @api.multi - def confirm_paid(self): - res = super(AccountInvoice, self).confirm_paid() + def action_invoice_paid(self): + res = super(AccountInvoice, self).action_invoice_paid() todo = set() for invoice in self: for line in invoice.invoice_line_ids: diff --git a/addons/sale/tests/test_sale_order.py b/addons/sale/tests/test_sale_order.py index e8e9d6c4b98..fdbefe40d80 100644 --- a/addons/sale/tests/test_sale_order.py +++ b/addons/sale/tests/test_sale_order.py @@ -130,7 +130,7 @@ class TestSaleOrder(TestSale): 'currency_id': company.currency_id.id, } inv = self.env['account.invoice'].create(invoice_vals) - inv.signal_workflow('invoice_open') + inv.action_invoice_open() sol = so.order_line.filtered(lambda l: l.product_id == serv_cost) self.assertTrue(sol, 'Sale: cost invoicing does not add lines when confirming vendor invoice') self.assertTrue(sol.price_unit == 160 and sol.qty_delivered == 2 and sol.product_uom_qty == sol.qty_invoiced == 0, 'Sale: line is wrong after confirming vendor invoice') diff --git a/addons/sale_stock/tests/test_sale_stock.py b/addons/sale_stock/tests/test_sale_stock.py index f3c26ea1db2..8f9c887d78e 100644 --- a/addons/sale_stock/tests/test_sale_stock.py +++ b/addons/sale_stock/tests/test_sale_stock.py @@ -154,7 +154,7 @@ class TestSaleStock(TestSale): self.assertEqual(len(inv_1_id), 1, 'Sale Stock: only one invoice instead of "%s" should be created' % len(inv_1_id)) self.inv_1 = self.env['account.invoice'].browse(inv_1_id) self.assertEqual(self.inv_1.amount_untaxed, self.inv_1.amount_untaxed, 'Sale Stock: amount in SO and invoice should be the same') - self.inv_1.signal_workflow('invoice_open') + self.inv_1.action_invoice_open() # Create return picking StockReturnPicking = self.env['stock.return.picking'] diff --git a/addons/website_portal_sale/models/payment.py b/addons/website_portal_sale/models/payment.py index 8170cc37139..d52085ee8f4 100644 --- a/addons/website_portal_sale/models/payment.py +++ b/addons/website_portal_sale/models/payment.py @@ -22,7 +22,7 @@ class PaymentTransaction(models.Model): _logger.info('<%s> transaction completed, auto-generated invoice %s (ID %s) for %s (ID %s)', acquirer_name, created_invoice.name, created_invoice.id, tx.sale_order_id.name, tx.sale_order_id.id) - created_invoice.signal_workflow('invoice_open') + created_invoice.action_invoice_open() if tx.acquirer_id.journal_id: created_invoice.pay_and_reconcile(tx.acquirer_id.journal_id, pay_amount=created_invoice.amount_total) if created_invoice.payment_ids: |
