This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
116 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.. 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 | ||
|
||
|
||
============================================= | ||
GRAP - Invoices 'Verified' / 'To Check' state | ||
============================================= | ||
|
||
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 | ||
|
||
2. Add a 'To check' checkbox field on account move | ||
|
||
* 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. | ||
|
||
Roadmap / Known Issues | ||
====================== | ||
|
||
* rename the module into ```grap_invoice_state``` | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Sylvain LE GAL <https://twitter.com/legalsylvain> | ||
* Julien WESTE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="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). | ||
--> | ||
<openerp><data> | ||
|
||
<record id="account.group_account_manager" model="res.groups"> | ||
<field name="user" eval="[(4, ref('base.user_root'))]" /> | ||
</record> | ||
|
||
</data></openerp> |
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
invoice_verified_state/migrations/8.0.3.0.0/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# coding: utf-8 | ||
# Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
__name__ = u"Precompute 'move_to_check' field of account_invoice" | ||
|
||
|
||
def precompute_move_to_check(cr): | ||
sql = """ | ||
ALTER TABLE account_invoice ADD COLUMN move_to_check BOOLEAN; | ||
UPDATE account_invoice ai | ||
SET move_to_check = am.to_check | ||
FRoM account_move am | ||
WHERE ai.move_id = am.id; | ||
""" | ||
cr.execute(sql) | ||
|
||
|
||
def migrate(cr, version): | ||
if not version: | ||
return | ||
precompute_move_to_check(cr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
# coding: utf-8 | ||
from . import account_invoice | ||
from . import account_journal | ||
from . import account_move |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (C) 2013-Today: GRAP (<http://www.grap.coop/>) | ||
# 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.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_check(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'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (C) 2013-Today: GRAP (<http://www.grap.coop/>) | ||
# 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'.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (C) 2013-Today: GRAP (<http://www.grap.coop/>) | ||
# 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) |
File renamed without changes.
File renamed without changes.