Andrea Cometa has proposed merging lp:~coopenerp/openobject-italia/7.0-adding-intra-cee into lp:openobject-italia/7.0.
Requested reviews: Andrea Cometa (scigghia) Davide Corio @ LS (enlightx) For more details, see: https://code.launchpad.net/~coopenerp/openobject-italia/7.0-adding-intra-cee/+merge/210855 Aggiunto modulo per la gestione delle fatture INTRA CEE -- https://code.launchpad.net/~coopenerp/openobject-italia/7.0-adding-intra-cee/+merge/210855 Your team OpenERP Italia core devs is subscribed to branch lp:openobject-italia/7.0.
=== added directory 'l10n_it_invoice_intra_cee' === added file 'l10n_it_invoice_intra_cee/AUTHORS.txt' --- l10n_it_invoice_intra_cee/AUTHORS.txt 1970-01-01 00:00:00 +0000 +++ l10n_it_invoice_intra_cee/AUTHORS.txt 2014-03-13 16:52:59 +0000 @@ -0,0 +1,2 @@ +Francesco Apruzzese <supp...@coopenerp.it> +Andrea Gallina <supp...@coopenerp.it> === added file 'l10n_it_invoice_intra_cee/__init__.py' --- l10n_it_invoice_intra_cee/__init__.py 1970-01-01 00:00:00 +0000 +++ l10n_it_invoice_intra_cee/__init__.py 2014-03-13 16:52:59 +0000 @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014 CoOpenERP <i...@coopenerp.it> +# All Rights Reserved +# +# 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 <http://www.gnu.org/licenses/>. +# +############################################################################## + +import account === added file 'l10n_it_invoice_intra_cee/__openerp__.py' --- l10n_it_invoice_intra_cee/__openerp__.py 1970-01-01 00:00:00 +0000 +++ l10n_it_invoice_intra_cee/__openerp__.py 2014-03-13 16:52:59 +0000 @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014 CoOpenERP <i...@coopenerp.it> +# All Rights Reserved +# +# 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 <http://www.gnu.org/licenses/>. +# +############################################################################## + +{ + 'name': "Invoice Intra CEE", + 'version': '0.1', + 'category': 'Account', + 'description': """Manage Invoice for Intra CEE supplier""", + 'author': 'CoOpenERP <i...@coopenerp.it>', + 'website': 'http://www.coopenerp.it', + 'license': 'AGPL-3', + "depends": ['account'], + "init_xml": [], + "update_xml": [ + 'account/account_view.xml', + 'account/account_data.xml', + ], + "demo_xml": [], + "active": False, + "installable": True +} === added directory 'l10n_it_invoice_intra_cee/account' === added file 'l10n_it_invoice_intra_cee/account/__init__.py' --- l10n_it_invoice_intra_cee/account/__init__.py 1970-01-01 00:00:00 +0000 +++ l10n_it_invoice_intra_cee/account/__init__.py 2014-03-13 16:52:59 +0000 @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014 CoOpenERP <i...@coopenerp.it> +# All Rights Reserved +# +# 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 <http://www.gnu.org/licenses/>. +# +############################################################################## + +import account === added file 'l10n_it_invoice_intra_cee/account/account.py' --- l10n_it_invoice_intra_cee/account/account.py 1970-01-01 00:00:00 +0000 +++ l10n_it_invoice_intra_cee/account/account.py 2014-03-13 16:52:59 +0000 @@ -0,0 +1,219 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright (C) 2014 CoOpenERP <i...@coopenerp.it> +# All Rights Reserved +# +# 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 <http://www.gnu.org/licenses/>. +# +############################################################################## + +from osv import fields, osv +from openerp import netsvc +from tools.translate import _ +from copy import deepcopy + + +class account_fiscal_position(osv.osv): + + _inherit = 'account.fiscal.position' + + _columns = { + 'account_cee_id': fields.many2one('account.account', + 'Account CEE'), + 'journal_cee_id': fields.many2one('account.journal', + 'Journal Auto Invoice CEE'), + 'journal_transfer_entry_id': fields.many2one( + 'account.journal', + 'Transfer Entry Journal'), + 'active_intra_cee': fields.boolean('Active Intra CEE Management'), + } + + +class account_tax(osv.osv): + + _inherit = 'account.tax' + + _columns = { + 'auto_invoice_tax_id': fields.many2one('account.tax', + 'Auto Invoice Tax'), + } + + +class account_invoice(osv.osv): + + _inherit = 'account.invoice' + + _columns = { + 'transfer_entry_id': fields.many2one('account.move', + 'Transfer Entry', + ondelete="set null"), + 'auto_invoice_id': fields.many2one('account.invoice', + 'Auto Invoice', + ondelete="set null"), + } + + def create_auto_invoice(self, cr, uid, ids, context=None): + context = context or {} + new_invoice_ids = [] + account_move = self.pool.get('account.move') + wf_service = netsvc.LocalService("workflow") + for inv in self.browse(cr, uid, ids, context): + # ----- Apply Auto Invoice only on supplier invoice/refund + if not (inv.type == 'in_invoice' or inv.type == 'in_refund'): + continue + fiscal_position = inv.fiscal_position + # ----- Check if fiscal positon is active for intra CEE invoice + if not (fiscal_position and fiscal_position.active_intra_cee): + continue + # ----- keep relation between tax and relative intra cee tax + tax_relation = {} + for line in inv.invoice_line: + # ----- Check if taxes exist on each line + if not line.invoice_line_tax_id: + raise osv.except_osv( + _('Error'), + _('You must define a tax for each line in Intra CEE Invoice')) + # ----- Check if tax has autoinvoice tax + for tax in line.invoice_line_tax_id: + if not tax.auto_invoice_tax_id: + raise osv.except_osv( + _('Error'), + _('Set an Auto Invoice Tax for tax %s') % ( + tax.name)) + tax_relation.update( + {tax.id: tax.auto_invoice_tax_id.id}) + # ----- Get actual invoice copy + copy_inv = self.copy_data(cr, uid, inv.id, {}, context) + if not copy_inv: + continue + new_inv = deepcopy(copy_inv) + # ----- Change some data in new invoice + new_inv.update({ + 'type': inv.type.replace('in_', 'out_'), + 'origin': inv.number or '', + 'supplier_invoice_number': '', + 'internal_number': '', + 'number': '', + 'state': 'draft', + 'move_id': False, + 'account_id': fiscal_position.account_cee_id.id, + 'journal_id': fiscal_position.journal_cee_id.id, + }) + new_line = [] + for line in new_inv['invoice_line']: + vals = deepcopy(line[2]) + # ----- Change account in new invoice line + vals['account_id'] = fiscal_position.account_cee_id.id + # ----- Change tax in new invoice line + new_tax = [] + for tax in vals['invoice_line_tax_id']: + new_tax.append((6,0,[tax_relation[tax[2][0]]])) + vals['invoice_line_tax_id'] = new_tax + new_line.append((0, 0, vals)) + new_inv['invoice_line'] = new_line + # ----- Create Auto Invoice...Yeah!!!!! + auto_invoice_id = self.create(cr, uid, new_inv, context) + new_invoice_ids.append(auto_invoice_id) + # ----- Recompute taxes in new invoice + self.button_reset_taxes(cr, uid, [auto_invoice_id], context) + # ----- Validate invoice + wf_service.trg_validate(uid, 'account.invoice', + auto_invoice_id, 'invoice_open', cr) + self.write(cr, uid, auto_invoice_id, + {'residul': 0.0, 'state': 'paid'}) + # ----- + # Create tranfer entry movements + # ----- + account_move_line_vals = [] + # ----- Tax for supplier + debit_1 = credit_1 = 0.0 + debit_2 = credit_2 = 0.0 + debit_3 = credit_3 = 0.0 + if inv.type == 'in_invoice': + debit_1 = inv.amount_tax + debit_2 = inv.amount_untaxed + credit_3 = inv.amount_total + else: + credit_1 = inv.amount_tax + credit_2 = inv.amount_untaxed + debit_3 = inv.amount_total + account_move_line_vals.append((0, 0, { + 'name': 'Tax for Supplier', + 'debit': debit_1, + 'credit': credit_1, + 'partner_id': inv.partner_id.id, + 'account_id': inv.partner_id.property_account_payable.id, + })) + # ----- Products values + account_move_line_vals.append((0, 0, { + 'name': 'Products', + 'debit': debit_2, + 'credit': credit_2, + 'partner_id': inv.partner_id.id, + 'account_id': fiscal_position.account_cee_id.id, + })) + # ----- Invoice Total + account_move_line_vals.append((0, 0, { + 'name': 'Invoice Total', + 'debit': debit_3, + 'credit': credit_3, + 'partner_id': inv.partner_id.id, + 'account_id': inv.partner_id.property_account_receivable.id, + })) + # ----- Account Move + account_move_vals = { + 'name': '/', + 'state': 'draft', + 'journal_id': fiscal_position.journal_transfer_entry_id.id, + 'line_id': account_move_line_vals, + } + transfer_entry_id = account_move.create( + cr, uid, account_move_vals, context) + account_move.post(cr, uid, [transfer_entry_id], context) + # ----- Link the tranfer entry move and auto invoice to supplier invoice + self.write(cr, uid, [inv.id], + {'auto_invoice_id': auto_invoice_id, + 'transfer_entry_id': transfer_entry_id}) + return new_invoice_ids + + def action_number(self, cr, uid, ids, context=None): + res = super(account_invoice,self).action_number(cr, uid, + ids, context) + self.create_auto_invoice(cr, uid, ids, context) + return res + + def action_cancel(self, cr, uid, ids, context=None): + invoices = self.browse(cr, uid, ids, context) + account_move = self.pool.get('account.move') + wf_service = netsvc.LocalService("workflow") + move_ids = [] + for inv in invoices: + # ----- Delete Auto Invoice + if inv.auto_invoice_id: + wf_service.trg_validate(uid, 'account.invoice', + inv.auto_invoice_id.id, + 'invoice_cancel', cr) + self.action_cancel_draft( + cr, uid, [inv.auto_invoice_id.id]) + self.unlink(cr, uid, [inv.auto_invoice_id.id], context) + # ----- Save account move ids + if inv.transfer_entry_id: + move_ids.append(inv.transfer_entry_id.id) + # ----- Reopen and delete account move + if move_ids: + account_move.button_cancel(cr, uid, move_ids, context) + account_move.unlink(cr, uid, move_ids, context) + return super(account_invoice,self).action_cancel( + cr, uid, ids, context) === added file 'l10n_it_invoice_intra_cee/account/account_data.xml' --- l10n_it_invoice_intra_cee/account/account_data.xml 1970-01-01 00:00:00 +0000 +++ l10n_it_invoice_intra_cee/account/account_data.xml 2014-03-13 16:52:59 +0000 @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data noupdate="1"> + + <record id="auto_invoice_journal_sequence" model="ir.sequence"> + <field name="name">Auto Invoice Journal Sequence</field> + <field eval="3" name="padding"/> + <field name="implementation">no_gap</field> + <field name="prefix">AIJ/%(year)s/</field> + </record> + <record id="transfert_entry_journal_sequence" model="ir.sequence"> + <field name="name">Transfert Entry Journal Sequence</field> + <field eval="3" name="padding"/> + <field name="implementation">no_gap</field> + <field name="prefix">TEJ/%(year)s/</field> + </record> + + <record forcecreate="1" id="auto_invoice_journal" model="account.journal"> + <field name="name">Auto Invoice Journal</field> + <field name="code">AIJ</field> + <field name="type">sale</field> + <field name="sequence_id" ref="auto_invoice_journal_sequence"/> + </record> + <record forcecreate="1" id="transfert_entry_invoice_journal" model="account.journal"> + <field name="name">Transfert Entry Journal</field> + <field name="code">TEJ</field> + <field name="type">general</field> + <field name="sequence_id" ref="transfert_entry_journal_sequence"/> + </record> + + </data> +</openerp> === added file 'l10n_it_invoice_intra_cee/account/account_view.xml' --- l10n_it_invoice_intra_cee/account/account_view.xml 1970-01-01 00:00:00 +0000 +++ l10n_it_invoice_intra_cee/account/account_view.xml 2014-03-13 16:52:59 +0000 @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> +<data> + + <!-- FISCAL POSITION FORM --> + + <record id="intra_cee_view_account_position_form" model="ir.ui.view"> + <field name="name">intra_cee.account_position.form</field> + <field name="model">account.fiscal.position</field> + <field name="inherit_id" ref="account.view_account_position_form"/> + <field name="arch" type="xml"> + <xpath expr="/form/separator[@string='Taxes Mapping']" position="before"> + <group> + <separator string="Intra CEE Configuration" colspan="4" /> + <group col="4"> + <field name="active_intra_cee" /> + <field name="account_cee_id" attrs="{'required':[('active_intra_cee', '=', True)]}"/> + </group> + </group> + <group> + <group col="4"> + <field name="journal_transfer_entry_id" attrs="{'required':[('active_intra_cee', '=', True)]}"/> + <field name="journal_cee_id" attrs="{'required':[('active_intra_cee', '=', True)]}"/> + </group> + </group> + </xpath> + </field> + </record> + + <!-- TAX FORM --> + + <record id="intra_cee_view_tax_form" model="ir.ui.view"> + <field name="name">intra_cee.account_tax.form</field> + <field name="model">account.tax</field> + <field name="inherit_id" ref="account.view_tax_form"/> + <field name="arch" type="xml"> + <xpath expr="/form/notebook/page[@string='Tax Definition']/group/group[@string='Misc']" position="after"> + <group string="Auto Invoice"> + <field name="auto_invoice_tax_id" /> + </group> + <newline /> + </xpath> + </field> + </record> + + <!-- SUPPLIER INVOICE FORM --> + + <record id="intra_cee_invoice_supplier_form" model="ir.ui.view"> + <field name="name">intra_cee.invoice_supplier.form</field> + <field name="model">account.invoice</field> + <field name="inherit_id" ref="account.invoice_supplier_form"/> + <field name="arch" type="xml"> + <field name="move_id" position="after"> + <field name="transfer_entry_id" groups="account.group_account_user" + readonly="True"/> + <field name="auto_invoice_id" groups="account.group_account_user" + readonly="True"/> + </field> + </field> + </record> + +</data> +</openerp> === added directory 'l10n_it_invoice_intra_cee/i18n' === added file 'l10n_it_invoice_intra_cee/i18n/it.po' --- l10n_it_invoice_intra_cee/i18n/it.po 1970-01-01 00:00:00 +0000 +++ l10n_it_invoice_intra_cee/i18n/it.po 2014-03-13 16:52:59 +0000 @@ -0,0 +1,91 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * l10n_it_invoice_intra_cee +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 7.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-03-13 15:32+0000\n" +"PO-Revision-Date: 2014-03-13 15:32+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_it_invoice_intra_cee +#: field:account.fiscal.position,journal_cee_id:0 +msgid "Journal Auto Invoice CEE" +msgstr "Sezionale Auto Fattura CEE" + +#. module: l10n_it_invoice_intra_cee +#: field:account.fiscal.position,account_cee_id:0 +msgid "Account CEE" +msgstr "Conto CEE" + +#. module: l10n_it_invoice_intra_cee +#: code:addons/l10n_it_invoice_intra_cee/account/account.py:101 +#, python-format +msgid "Set an Auto Invoice Tax for tax %s" +msgstr "Imposare l'aliquota dell'auto fattura per l'aliquota IVA %s" + +#. module: l10n_it_invoice_intra_cee +#: view:account.fiscal.position:0 +msgid "Intra CEE Configuration" +msgstr "Configurazione Intra CEE" + +#. module: l10n_it_invoice_intra_cee +#: model:ir.model,name:l10n_it_invoice_intra_cee.model_account_tax +msgid "Tax" +msgstr "Imposta" + +#. module: l10n_it_invoice_intra_cee +#: field:account.invoice,auto_invoice_id:0 +#: view:account.tax:0 +msgid "Auto Invoice" +msgstr "Auto Fattura" + +#. module: l10n_it_invoice_intra_cee +#: field:account.invoice,transfer_entry_id:0 +msgid "Transfer Entry" +msgstr "Giroconto" + +#. module: l10n_it_invoice_intra_cee +#: field:account.fiscal.position,active_intra_cee:0 +msgid "Active Intra CEE Management" +msgstr "Attiva Gestione Intra CEE" + +#. module: l10n_it_invoice_intra_cee +#: model:ir.model,name:l10n_it_invoice_intra_cee.model_account_fiscal_position +msgid "Fiscal Position" +msgstr "Posizione fiscale" + +#. module: l10n_it_invoice_intra_cee +#: model:ir.model,name:l10n_it_invoice_intra_cee.model_account_invoice +msgid "Invoice" +msgstr "Fattura" + +#. module: l10n_it_invoice_intra_cee +#: code:addons/l10n_it_invoice_intra_cee/account/account.py:94 +#: code:addons/l10n_it_invoice_intra_cee/account/account.py:100 +#, python-format +msgid "Error" +msgstr "Errore" + +#. module: l10n_it_invoice_intra_cee +#: code:addons/l10n_it_invoice_intra_cee/account/account.py:95 +#, python-format +msgid "You must define a tax for each line in Intra CEE Invoice" +msgstr "Bisogna definire almeno un'aliquota IVA per ogni dettaglio delle fatture soggette ad Intra CEE" + +#. module: l10n_it_invoice_intra_cee +#: field:account.fiscal.position,journal_transfer_entry_id:0 +msgid "Transfer Entry Journal" +msgstr "Sezionale Giroconto" + +#. module: l10n_it_invoice_intra_cee +#: field:account.tax,auto_invoice_tax_id:0 +msgid "Auto Invoice Tax" +msgstr "Aliquota Auto Fattura"
_______________________________________________ Mailing list: https://launchpad.net/~openobject-italia-core-devs Post to : openobject-italia-core-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~openobject-italia-core-devs More help : https://help.launchpad.net/ListHelp