diff --git a/__unported__/account_default_draft_move/account.py b/__unported__/account_default_draft_move/account.py deleted file mode 100644 index b73275ca0..000000000 --- a/__unported__/account_default_draft_move/account.py +++ /dev/null @@ -1,64 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author Vincent Renaville/Joel Grand-Guillaume. -# Copyright 2012 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -############################################################################## - -from openerp.osv import orm, osv -from tools.translate import _ - - -class AccountInvoice(orm.Model): - _inherit = 'account.invoice' - - def action_move_create(self, cr, uid, ids, context=None): - """Set move line in draft state after creating them.""" - res = super(AccountInvoice, self).action_move_create(cr, uid, ids, - context=context) - move_obj = self.pool.get('account.move') - for inv in self.browse(cr, uid, ids, context=context): - if inv.move_id: - move_obj.write(cr, uid, [inv.move_id.id], {'state': 'draft'}, - context=context) - return res - - -class AccountMove(orm.Model): - _inherit = 'account.move' - - def button_cancel(self, cr, uid, ids, context=None): - """ We rewrite function button_cancel, to allow invoice or bank - statement with linked draft moved - to be canceled - - """ - for line in self.browse(cr, uid, ids, context=context): - if line.state == 'draft': - continue - else: - if not line.journal_id.update_posted: - raise osv.except_osv( - _('Error!'), - _('You cannot modify a posted entry of this journal.' - 'First you should set the journal ' - 'to allow cancelling entries.') - ) - if ids: - cr.execute('UPDATE account_move ' - 'SET state=%s ' - 'WHERE id IN %s', ('draft', tuple(ids),)) - return True diff --git a/__unported__/account_default_draft_move/account_bank_statement.py b/__unported__/account_default_draft_move/account_bank_statement.py deleted file mode 100644 index 5a966ed81..000000000 --- a/__unported__/account_default_draft_move/account_bank_statement.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Author Vincent Renaville. Copyright 2012 Camptocamp SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -############################################################################## - -from openerp.osv import orm - - -class AccountBankStatement(orm.Model): - _inherit = "account.bank.statement" - - def create_move_from_st_line(self, cr, uid, - st_line_id, company_currency_id, - st_line_number, context=None): - move_ids = super(AccountBankStatement, self).create_move_from_st_line( - cr, uid, st_line_id, company_currency_id, - st_line_number, context - ) - # If a bank statement line is already linked to a voucher - # we received boolean instead of voucher move ids in move_ids - bank_st_line_obj = self.pool.get('account.bank.statement.line') - voucher_obj = self.pool.get('account.voucher') - st_line = bank_st_line_obj.browse(cr, uid, st_line_id, context=context) - if st_line.voucher_id: - v = voucher_obj.browse(cr, uid, st_line.voucher_id.id, - context=context) - move_ids = v.move_id.id - - if not isinstance(move_ids, (tuple, list)): - move_ids = [move_ids] - # We receive the move created for the bank statement, we set it - # to draft - if move_ids: - move_obj = self.pool.get('account.move') - move_obj.write(cr, uid, move_ids, - {'state': 'draft'}, context=context) - return move_ids -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/__unported__/account_constraints/__init__.py b/account_constraints/__init__.py similarity index 100% rename from __unported__/account_constraints/__init__.py rename to account_constraints/__init__.py diff --git a/__unported__/account_constraints/__openerp__.py b/account_constraints/__openerp__.py similarity index 95% rename from __unported__/account_constraints/__openerp__.py rename to account_constraints/__openerp__.py index c5ab4d7f8..06bda34e3 100644 --- a/__unported__/account_constraints/__openerp__.py +++ b/account_constraints/__openerp__.py @@ -18,7 +18,7 @@ # ############################################################################## { - 'name': 'Account Constraints', + 'name': 'Account Constraints 8.0', 'version': '1.1', 'depends': ['account'], 'author': 'Camptocamp', @@ -51,8 +51,8 @@ Summary of constraints are: invoice or a bank statement, no matter what the status of the move (draft, validated or posted). This is useful in a standard context but even more if you're using `account_default_draft_move`. This way you ensure - that the user cannot make mistakes even in draft state, he must pass - through the parent object to make his modification. + that the user cannot make mistakes even in draft state, he must pass through + the parent object to make his modification. Contributors * Stéphane Bidoul @@ -62,5 +62,5 @@ Summary of constraints are: 'data': [ 'view/account_journal.xml', ], - 'installable': False, + 'installable': True, } diff --git a/__unported__/account_constraints/account_constraints.py b/account_constraints/account_constraints.py similarity index 100% rename from __unported__/account_constraints/account_constraints.py rename to account_constraints/account_constraints.py diff --git a/__unported__/account_constraints/i18n/account_constraints.pot b/account_constraints/i18n/account_constraints.pot similarity index 100% rename from __unported__/account_constraints/i18n/account_constraints.pot rename to account_constraints/i18n/account_constraints.pot diff --git a/__unported__/account_constraints/i18n/pt_BR.po b/account_constraints/i18n/pt_BR.po similarity index 100% rename from __unported__/account_constraints/i18n/pt_BR.po rename to account_constraints/i18n/pt_BR.po diff --git a/__unported__/account_constraints/view/account_journal.xml b/account_constraints/view/account_journal.xml similarity index 100% rename from __unported__/account_constraints/view/account_journal.xml rename to account_constraints/view/account_journal.xml diff --git a/__unported__/account_default_draft_move/__init__.py b/account_default_draft_move/__init__.py similarity index 100% rename from __unported__/account_default_draft_move/__init__.py rename to account_default_draft_move/__init__.py diff --git a/__unported__/account_default_draft_move/__openerp__.py b/account_default_draft_move/__openerp__.py similarity index 93% rename from __unported__/account_default_draft_move/__openerp__.py rename to account_default_draft_move/__openerp__.py index 748b33e3e..7e0502478 100644 --- a/__unported__/account_default_draft_move/__openerp__.py +++ b/account_default_draft_move/__openerp__.py @@ -18,9 +18,9 @@ # along with this program. If not, see . ############################################################################## { - "name": "Move in draft state by default", + "name": "Move in draft state by default 8.0", "version": "1.0", - "depends": ["base", "account", "account_constraints"], + "depends": ["base", "account", "account_constraints_80"], "author": "Camptocamp", 'license': 'AGPL-3', "description": """ @@ -51,7 +51,7 @@ need to make a refund). 'website': 'http://www.camptocamp.com', 'data': ['account_view.xml', 'invoice_view.xml'], - 'installable': False, - 'active': False, + 'installable': True, + 'active': True, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_default_draft_move/account.py b/account_default_draft_move/account.py new file mode 100644 index 000000000..2b488ecde --- /dev/null +++ b/account_default_draft_move/account.py @@ -0,0 +1,62 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Vincent Renaville/Joel Grand-Guillaume.Copyright 2012 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +############################################################################## + +from openerp import models, api +from openerp.tools.translate import _ + + +class AccountInvoice(models.Model): + _inherit = 'account.invoice' + + @api.multi + def action_move_create(self): + """Set move line in draft state after creating them.""" + res = super(AccountInvoice, self).action_move_create() + for inv in self: + if inv.move_id: + inv.move_id.write({'state': 'draft'}) + return res + + +class AccountMove(models.Model): + _inherit = 'account.move' + + @api.multi + def button_cancel(self): + """ We rewrite function button_cancel, to allow invoice or bank + statement with linked draft moved + to be canceled """ + for line in self: + if line.state == 'draft': + continue + else: + if not line.journal_id.update_posted: + raise models.except_orm( + _('Error!'), + _('You cannot modify a posted entry of this journal.' + 'First you should set the journal to allow' + ' cancelling entries.') + ) + if self: + self._cr.execute('UPDATE account_move ' + 'SET state=%s ' + 'WHERE id IN %s', ('draft', self._ids,)) + return True + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/account_default_draft_move/account_bank_statement.py b/account_default_draft_move/account_bank_statement.py new file mode 100644 index 000000000..c69e11ad7 --- /dev/null +++ b/account_default_draft_move/account_bank_statement.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Author Vincent Renaville. Copyright 2012 Camptocamp SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +############################################################################## + +from openerp import models, api + + +class AccountBankStatement(models.Model): + _inherit = "account.bank.statement" + + @api.multi + def button_confirm_bank(self): + res = super(AccountBankStatement, self).button_confirm_bank() + for st in self: + for st_line in st.line_ids: + st_line.journal_entry_id.write({'state': 'draft'}) + return res diff --git a/__unported__/account_default_draft_move/account_view.xml b/account_default_draft_move/account_view.xml similarity index 100% rename from __unported__/account_default_draft_move/account_view.xml rename to account_default_draft_move/account_view.xml diff --git a/__unported__/account_default_draft_move/i18n/account_default_draft_move.pot b/account_default_draft_move/i18n/account_default_draft_move.pot similarity index 100% rename from __unported__/account_default_draft_move/i18n/account_default_draft_move.pot rename to account_default_draft_move/i18n/account_default_draft_move.pot diff --git a/__unported__/account_default_draft_move/i18n/en.po b/account_default_draft_move/i18n/en.po similarity index 100% rename from __unported__/account_default_draft_move/i18n/en.po rename to account_default_draft_move/i18n/en.po diff --git a/__unported__/account_default_draft_move/i18n/fr.po b/account_default_draft_move/i18n/fr.po similarity index 100% rename from __unported__/account_default_draft_move/i18n/fr.po rename to account_default_draft_move/i18n/fr.po diff --git a/__unported__/account_default_draft_move/i18n/pt_BR.po b/account_default_draft_move/i18n/pt_BR.po similarity index 100% rename from __unported__/account_default_draft_move/i18n/pt_BR.po rename to account_default_draft_move/i18n/pt_BR.po diff --git a/__unported__/account_default_draft_move/invoice_view.xml b/account_default_draft_move/invoice_view.xml similarity index 100% rename from __unported__/account_default_draft_move/invoice_view.xml rename to account_default_draft_move/invoice_view.xml