From 9f114c01f03af6f520cf41ac2a4513e344e30fae Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 19 Oct 2018 11:47:53 +0200 Subject: [PATCH 1/5] [REF] invoice_verified_state --- invoice_verified_state/README.rst | 34 ++++++++ invoice_verified_state/__openerp__.py | 6 +- invoice_verified_state/demo/res_groups.xml | 14 ++++ invoice_verified_state/demo/res_groups.yml | 10 --- invoice_verified_state/models/__init__.py | 2 +- .../models/account_invoice.py | 84 ++++--------------- .../models/account_journal.py | 21 ++--- invoice_verified_state/models/account_move.py | 19 +++-- 8 files changed, 89 insertions(+), 101 deletions(-) create mode 100644 invoice_verified_state/README.rst create mode 100644 invoice_verified_state/demo/res_groups.xml delete mode 100644 invoice_verified_state/demo/res_groups.yml diff --git a/invoice_verified_state/README.rst b/invoice_verified_state/README.rst new file mode 100644 index 0000000..c2fcd10 --- /dev/null +++ b/invoice_verified_state/README.rst @@ -0,0 +1,34 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + + +===================================================================== +Easy Switch between VAT Excluded and VAT Included For Purchase Module +===================================================================== + +Possibility to switch between Price VAT Included and Price VAT Excluded +when editing a Purchase Order. + + +* Possibility to switch between Price VAT Included and Price VAT Excluded + when editing a Purchase Order + +** Purchase Orders with Mixed Taxes** + +.. image:: /simple_tax_purchase/static/description/purchase_harmonized_taxes.png + +** Purchase Orders with Harmonized Taxes** + +.. image:: /simple_tax_purchase/static/description/purchase_mixed_taxes.png + + +See simple_tax_account for more detailled information. + +Credits +======= + +Contributors +------------ + +* Sylvain LE GAL diff --git a/invoice_verified_state/__openerp__.py b/invoice_verified_state/__openerp__.py index a984b66..e5b982c 100644 --- a/invoice_verified_state/__openerp__.py +++ b/invoice_verified_state/__openerp__.py @@ -5,9 +5,9 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { - 'name': "Account - Invoice 'Verified' state", - 'version': '7.0.1.0.0', - 'category': 'Accounting', + 'name': "GRAP - Invoices 'Verified' / 'To Check' state", + 'version': '8.0.1.0.0', + 'category': 'Custom', 'description': """ Add a 'Verified' state on account.invoice ========================================= diff --git a/invoice_verified_state/demo/res_groups.xml b/invoice_verified_state/demo/res_groups.xml new file mode 100644 index 0000000..fda89ed --- /dev/null +++ b/invoice_verified_state/demo/res_groups.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/invoice_verified_state/demo/res_groups.yml b/invoice_verified_state/demo/res_groups.yml deleted file mode 100644 index 64658a9..0000000 --- a/invoice_verified_state/demo/res_groups.yml +++ /dev/null @@ -1,10 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2013-Today: GRAP () -# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) -# @author: Julien WESTE -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - - -- !record {model: res.groups, id: account.group_account_manager}: - users: - - base.user_root diff --git a/invoice_verified_state/models/__init__.py b/invoice_verified_state/models/__init__.py index 2fa8b4b..71e791b 100644 --- a/invoice_verified_state/models/__init__.py +++ b/invoice_verified_state/models/__init__.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 from . import account_invoice from . import account_journal from . import account_move diff --git a/invoice_verified_state/models/account_invoice.py b/invoice_verified_state/models/account_invoice.py index 5c5d192..8420720 100644 --- a/invoice_verified_state/models/account_invoice.py +++ b/invoice_verified_state/models/account_invoice.py @@ -1,83 +1,35 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2013-Today: GRAP () +# coding: utf-8 +# Copyright (C) 2013 - Today: GRAP (http://www.grap.coop) # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) -# @author: Julien WESTE # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp.osv.orm import Model -from openerp.osv import fields -from openerp.osv import osv -from openerp.tools.translate import _ +from openerp import _, api, fields, models +from openerp.exceptions import Warning as UserError -class AccountInvoice(Model): - _inherit = 'account.invoice' - - _ACCOUNT_INVOICE_STATE = [ - ('draft', 'Draft'), - ('verified', _('Verified')), - ('proforma', 'Pro-forma'), - ('proforma2', 'Pro-forma'), - ('open', 'Open'), - ('paid', 'Paid'), - ('cancel', 'Cancelled'), - ] - def _search_move_to_check(self, cr, uid, obj, name, arg, context=None): - am_obj = self.pool['account.move'] - ai_obj = self.pool['account.invoice'] - am_ids = am_obj.search( - cr, uid, [('to_check', '=', True)], context=context) - ai_ids = ai_obj.search( - cr, uid, [('move_id', 'in', am_ids)], context=context) - return [('id', 'in', ai_ids)] +class AccountInvoice(models.Model): + _inherit = 'account.invoice' - def button_move_check(self, cr, uid, ids, context=None): - am_obj = self.pool['account.move'] - am_ids = [] - for ai in self.browse(cr, uid, ids, context=context): - if ai.move_id: - am_ids.append(ai.move_id.id) - am_obj.write(cr, uid, am_ids, {'to_check': False}, context=context) - return True + move_to_check = fields.Boolean( + string='Move To Check', related='move_id.move_to_check', store=True) - def _get_move_to_check(self, cr, uid, ids, name, arg, context=None): - res = {} - for item in self.browse(cr, uid, ids, context=context): - res[item.id] = item.move_id and item.move_id.to_check or False - return res + state = fields.Selection(selection_add=[('verified', ('Verified'))]) - _columns = { - 'move_to_check': fields.function( - _get_move_to_check, type='boolean', string='Move To Check', - fnct_search=_search_move_to_check), - 'state': fields.selection( - _ACCOUNT_INVOICE_STATE, string='State', select=True, readonly=True, - help="* The 'Draft' state is used when a user is encoding" - " a new and unconfirmed Invoice." - "\n* The 'Pro-forma' when invoice is in Pro-forma state," - " invoice does not have an invoice number." - "\n* The 'Verified' state is used when the user has checked" - " that the invoice is conform to what he expected and is" - " ready to be processed by the accountants." - "\n* The 'Open' state is used when user create invoice," - " a invoice number is generated.Its in open state till user" - " does not pay invoice." - "\n* The 'Paid' state is set automatically when the invoice" - " is paid. Its related journal entries may or may not be" - " reconciled." - "\n* The 'Cancelled' state is used when user cancel invoice."), - } + @api.multi + def button_move_checked(self): + moves = self.mapped('move_id') + moves.write({'to_check': False}) - def wkf_verify_invoice(self, cr, uid, ids, context=None): - for invoice in self.browse(cr, uid, ids, context=context): + @api.multi + def wkf_verify_invoice(self): + for invoice in self: if not invoice.date_invoice or not invoice.date_due\ or not invoice.supplier_invoice_number: - raise osv.except_osv(_('Error!'), _( + raise UserError(_( "Verify a supplier invoice requires to set the following" " fields :\n" "* 'Invoice Date';\n" "* 'Due Date';\n" "* 'Supplier Invoice Number';")) - self.write(cr, uid, ids, {'state': 'verified'}) - return True + self.write({'state': 'verified'}) diff --git a/invoice_verified_state/models/account_journal.py b/invoice_verified_state/models/account_journal.py index c43338f..880cdc7 100644 --- a/invoice_verified_state/models/account_journal.py +++ b/invoice_verified_state/models/account_journal.py @@ -1,19 +1,16 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2013-Today: GRAP () +# coding: utf-8 +# Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) -# @author: Julien WESTE # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp.osv import fields -from openerp.osv.orm import Model +from openerp import fields, models -class AccountJournal(Model): + +class AccountJournal(models.Model): _inherit = 'account.journal' - _columns = { - 'move_to_check': fields.boolean( - string='Moves to Check', help="If you check this box," - " account moves created in this journal" - " will be marked as 'To check by a financial manager'."), - } + move_to_check = fields.Boolean( + string='Moves to Check', help="If you check this box," + " account moves created in this journal" + " will be marked as 'To check by a financial manager'.") diff --git a/invoice_verified_state/models/account_move.py b/invoice_verified_state/models/account_move.py index 5d9d210..e4b9af9 100644 --- a/invoice_verified_state/models/account_move.py +++ b/invoice_verified_state/models/account_move.py @@ -1,19 +1,20 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2013-Today: GRAP () +# coding: utf-8 +# Copyright (C) 2013 - Today: GRAP (http://www.grap.coop) # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # @author: Julien WESTE # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from openerp.osv.orm import Model +from openerp import api, models -class AccountMove(Model): +class AccountMove(models.Model): _inherit = 'account.move' - def create(self, cr, uid, vals, context=None): - journal_obj = self.pool['account.journal'] + @api.model + def create(self, vals): + AccountJournal = self.env['account.journal'] if vals.get('journal_id', False) and not vals.get('to_check'): - journal = journal_obj.browse( - cr, uid, vals['journal_id'], context=context) + journal = AccountJournal.browse( + vals['journal_id']) vals['to_check'] = journal.move_to_check - return super(AccountMove, self).create(cr, uid, vals, context=context) + return super(AccountMove, self).create(vals) From 563e085d52f5a083952f18b09cad1811de46f848 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 19 Oct 2018 12:08:02 +0200 Subject: [PATCH 2/5] [REF] invoice_verified_state --- invoice_verified_state/README.rst | 31 ++++++++++--------- ...oice_view.xml => view_account_invoice.xml} | 0 ...rnal_view.xml => view_account_journal.xml} | 0 3 files changed, 16 insertions(+), 15 deletions(-) rename invoice_verified_state/views/{account_invoice_view.xml => view_account_invoice.xml} (100%) rename invoice_verified_state/views/{account_journal_view.xml => view_account_journal.xml} (100%) diff --git a/invoice_verified_state/README.rst b/invoice_verified_state/README.rst index c2fcd10..6fe0971 100644 --- a/invoice_verified_state/README.rst +++ b/invoice_verified_state/README.rst @@ -3,27 +3,27 @@ :alt: License: AGPL-3 -===================================================================== -Easy Switch between VAT Excluded and VAT Included For Purchase Module -===================================================================== +============================================= +GRAP - Invoices 'Verified' / 'To Check' state +============================================= -Possibility to switch between Price VAT Included and Price VAT Excluded -when editing a Purchase Order. +1. Add a 'Verified' state on account.invoice (supplier and supplier refund + invoices) +* Only Accounting managers can validate supplier account invoices +* the workflow is so modified -* Possibility to switch between Price VAT Included and Price VAT Excluded - when editing a Purchase Order +2. Add a 'To check' checkbox field on account move -** Purchase Orders with Mixed Taxes** +* The setting is done per journal +* if a journal is set to 'To Check' all the accounting moves will be set as + 'To Check'. this feature is usefull with the module to export to EBP, to + prevent import of moves that has not been controled by accounting managers. -.. image:: /simple_tax_purchase/static/description/purchase_harmonized_taxes.png +Roadmap / Known Issues +====================== -** Purchase Orders with Harmonized Taxes** - -.. image:: /simple_tax_purchase/static/description/purchase_mixed_taxes.png - - -See simple_tax_account for more detailled information. +* rename the module into ```grap_invoice_state``` Credits ======= @@ -32,3 +32,4 @@ Contributors ------------ * Sylvain LE GAL +* Julien WESTE diff --git a/invoice_verified_state/views/account_invoice_view.xml b/invoice_verified_state/views/view_account_invoice.xml similarity index 100% rename from invoice_verified_state/views/account_invoice_view.xml rename to invoice_verified_state/views/view_account_invoice.xml diff --git a/invoice_verified_state/views/account_journal_view.xml b/invoice_verified_state/views/view_account_journal.xml similarity index 100% rename from invoice_verified_state/views/account_journal_view.xml rename to invoice_verified_state/views/view_account_journal.xml From 40c079580d1c08f61b16edea67908487062960ea Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 19 Oct 2018 12:13:18 +0200 Subject: [PATCH 3/5] [fix] description --- invoice_verified_state/__openerp__.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/invoice_verified_state/__openerp__.py b/invoice_verified_state/__openerp__.py index e5b982c..45b53a2 100644 --- a/invoice_verified_state/__openerp__.py +++ b/invoice_verified_state/__openerp__.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# coding: utf-8 # Copyright (C) 2013-Today: GRAP () # @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # @author: Julien WESTE @@ -8,32 +8,15 @@ 'name': "GRAP - Invoices 'Verified' / 'To Check' state", 'version': '8.0.1.0.0', 'category': 'Custom', - 'description': """ -Add a 'Verified' state on account.invoice -========================================= - -* Add a Verified state on account.invoice; -* Only Account_manager can validate supplier account.invoice; -* Modify the corresponding workflow; - -Copyright, Author and Licence ------------------------------ - -* Copyright : 2013, Groupement Régional Alimentaire de Proximité; -* Author : - * Julien WESTE; -* Licence : AGPL-3 (http://www.gnu.org/licenses/) - """, 'author': 'GRAP', 'website': 'http://www.grap.coop', 'license': 'AGPL-3', 'depends': [ - 'account', 'account_voucher', ], 'data': [ - 'views/account_invoice_view.xml', - 'views/account_journal_view.xml', + 'views/view_account_invoice.xml', + 'views/view_account_journal.xml', 'data/workflow.xml', ], 'demo': [ From 127de9e1fcd1151fd4feecdbadbe6b453580a41e Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 19 Oct 2018 18:52:41 +0200 Subject: [PATCH 4/5] [FIX] incorrect related field --- invoice_verified_state/models/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/invoice_verified_state/models/account_invoice.py b/invoice_verified_state/models/account_invoice.py index 8420720..2982213 100644 --- a/invoice_verified_state/models/account_invoice.py +++ b/invoice_verified_state/models/account_invoice.py @@ -12,7 +12,7 @@ class AccountInvoice(models.Model): _inherit = 'account.invoice' move_to_check = fields.Boolean( - string='Move To Check', related='move_id.move_to_check', store=True) + string='Move To Check', related='move_id.to_check', store=True) state = fields.Selection(selection_add=[('verified', ('Verified'))]) From 2a59e19ab855615bc719510e68d9e76582b5365d Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 19 Oct 2018 18:56:04 +0200 Subject: [PATCH 5/5] [FIX] function name --- invoice_verified_state/models/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/invoice_verified_state/models/account_invoice.py b/invoice_verified_state/models/account_invoice.py index 2982213..51d3740 100644 --- a/invoice_verified_state/models/account_invoice.py +++ b/invoice_verified_state/models/account_invoice.py @@ -17,7 +17,7 @@ class AccountInvoice(models.Model): state = fields.Selection(selection_add=[('verified', ('Verified'))]) @api.multi - def button_move_checked(self): + def button_move_check(self): moves = self.mapped('move_id') moves.write({'to_check': False})