← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~agilebg/account-invoicing/adding_stock_invoice_picking_incoterm_7 into lp:account-invoicing

 

Alex Comba - Agile BG has proposed merging lp:~agilebg/account-invoicing/adding_stock_invoice_picking_incoterm_7 into lp:account-invoicing.

Commit message:
[ADD] module stock_invoice_picking_incoterm

Requested reviews:
  Account Core Editors (account-core-editors)

For more details, see:
https://code.launchpad.net/~agilebg/account-invoicing/adding_stock_invoice_picking_incoterm_7/+merge/213987

I added the module named 'stock_invoice_picking_incoterm'.

It adds the field incoterm to invoice and picking. In this way the user can specify the incoterm directly on these documents, with no need to refer to the incoterm of the order (which could even be missing). The module extends 'stock_invoice_picking' so that the invoices created from pickings will have the same incoterm set in the picking.
-- 
https://code.launchpad.net/~agilebg/account-invoicing/adding_stock_invoice_picking_incoterm_7/+merge/213987
Your team Account Core Editors is requested to review the proposed merge of lp:~agilebg/account-invoicing/adding_stock_invoice_picking_incoterm_7 into lp:account-invoicing.
=== added directory 'stock_invoice_picking_incoterm'
=== added file 'stock_invoice_picking_incoterm/__init__.py'
--- stock_invoice_picking_incoterm/__init__.py	1970-01-01 00:00:00 +0000
+++ stock_invoice_picking_incoterm/__init__.py	2014-04-03 09:46:52 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2014 Agile Business Group sagl
+#	 (<http://www.agilebg.com>)
+#
+#    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 . import account_invoice
+from . import stock

=== added file 'stock_invoice_picking_incoterm/__openerp__.py'
--- stock_invoice_picking_incoterm/__openerp__.py	1970-01-01 00:00:00 +0000
+++ stock_invoice_picking_incoterm/__openerp__.py	2014-04-03 09:46:52 +0000
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2014 Agile Business Group sagl
+#    (<http://www.agilebg.com>)
+#    @author Alex Comba <alex.comba@xxxxxxxxxxx>
+#
+#    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': "Stock Invoice Picking Incoterm",
+    'version': '0.1',
+    'category': 'Warehouse Management',
+    'description': """
+This module adds the field incoterm to invoice and picking. In this way the
+user can specify the incoterm directly on these documents, with no need to
+refer to the incoterm of the order (which could even be missing).
+The module extends 'stock_invoice_picking' so that the invoices created
+from pickings will have the same incoterm set in the picking.
+""",
+    'author': 'Agile Business Group',
+    'website': 'http://www.agilebg.com',
+    'license': 'AGPL-3',
+    'depends': [
+        'stock_invoice_picking',
+    ],
+    'data': [
+        'account_invoice_view.xml',
+        'stock_view.xml',
+    ],
+    'test': [
+        'test/invoice_picking_incoterm.yml',
+    ],
+    'active': False,
+    'installable': True
+}

=== added file 'stock_invoice_picking_incoterm/account_invoice.py'
--- stock_invoice_picking_incoterm/account_invoice.py	1970-01-01 00:00:00 +0000
+++ stock_invoice_picking_incoterm/account_invoice.py	2014-04-03 09:46:52 +0000
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2014 Agile Business Group sagl
+#    (<http://www.agilebg.com>)
+#
+#    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 openerp.osv import fields, orm
+
+
+class account_invoice(orm.Model):
+    _inherit = "account.invoice"
+
+    _columns = {
+        'incoterm': fields.many2one(
+            'stock.incoterms',
+            'Incoterm',
+            help="International Commercial Terms are a series of predefined \
+            commercial terms used in international transactions."
+        ),
+    }

=== added file 'stock_invoice_picking_incoterm/account_invoice_view.xml'
--- stock_invoice_picking_incoterm/account_invoice_view.xml	1970-01-01 00:00:00 +0000
+++ stock_invoice_picking_incoterm/account_invoice_view.xml	2014-04-03 09:46:52 +0000
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <record id="view_invoice_form" model="ir.ui.view">
+            <field name="name">account.invoice.form</field>
+            <field name="model">account.invoice</field>
+            <field name="inherit_id" ref="account.invoice_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="/form/sheet/notebook/page[@string='Other Info']/group/group/field[@name='date_due']" position="after">
+                    <field name="incoterm" widget="selection"/>
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>
\ No newline at end of file

=== added directory 'stock_invoice_picking_incoterm/i18n'
=== added file 'stock_invoice_picking_incoterm/i18n/it.po'
--- stock_invoice_picking_incoterm/i18n/it.po	1970-01-01 00:00:00 +0000
+++ stock_invoice_picking_incoterm/i18n/it.po	2014-04-03 09:46:52 +0000
@@ -0,0 +1,53 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# 	* stock_invoice_picking_incoterm
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-03-13 14:29+0000\n"
+"PO-Revision-Date: 2014-03-13 15:40+0100\n"
+"Last-Translator: Alex Comba <alex.comba@xxxxxxxxxxx>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+"X-Generator: Poedit 1.5.4\n"
+
+#. module: stock_invoice_picking_incoterm
+#: field:account.invoice,incoterm:0 field:stock.picking,incoterm:0
+#: field:stock.picking.in,incoterm:0 field:stock.picking.out,incoterm:0
+msgid "Incoterm"
+msgstr "Incoterm"
+
+#. module: stock_invoice_picking_incoterm
+#: model:ir.model,name:stock_invoice_picking_incoterm.model_stock_picking_in
+msgid "Incoming Shipments"
+msgstr "Spedizioni in entrata"
+
+#. module: stock_invoice_picking_incoterm
+#: help:account.invoice,incoterm:0 help:stock.picking,incoterm:0
+#: help:stock.picking.in,incoterm:0 help:stock.picking.out,incoterm:0
+msgid ""
+"International Commercial Terms are a series of predefined             "
+"commercial terms used in international transactions."
+msgstr ""
+"I termini commerciali internazionali sono una serie di termini "
+"commerciali             predefiniti usati nelle transazioni internazionali."
+
+#. module: stock_invoice_picking_incoterm
+#: model:ir.model,name:stock_invoice_picking_incoterm.model_account_invoice
+msgid "Invoice"
+msgstr "Fattura"
+
+#. module: stock_invoice_picking_incoterm
+#: model:ir.model,name:stock_invoice_picking_incoterm.model_stock_picking
+msgid "Picking List"
+msgstr "Picking List"
+
+#. module: stock_invoice_picking_incoterm
+#: model:ir.model,name:stock_invoice_picking_incoterm.model_stock_picking_out
+msgid "Delivery Orders"
+msgstr "Ordini di Consegna"

=== added file 'stock_invoice_picking_incoterm/i18n/stock_invoice_picking_incoterm.pot'
--- stock_invoice_picking_incoterm/i18n/stock_invoice_picking_incoterm.pot	1970-01-01 00:00:00 +0000
+++ stock_invoice_picking_incoterm/i18n/stock_invoice_picking_incoterm.pot	2014-04-03 09:46:52 +0000
@@ -0,0 +1,53 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* stock_invoice_picking_incoterm
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-03-13 14:27+0000\n"
+"PO-Revision-Date: 2014-03-13 14:27+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: stock_invoice_picking_incoterm
+#: field:account.invoice,incoterm:0
+#: field:stock.picking,incoterm:0
+#: field:stock.picking.in,incoterm:0
+#: field:stock.picking.out,incoterm:0
+msgid "Incoterm"
+msgstr ""
+
+#. module: stock_invoice_picking_incoterm
+#: model:ir.model,name:stock_invoice_picking_incoterm.model_stock_picking_in
+msgid "Incoming Shipments"
+msgstr ""
+
+#. module: stock_invoice_picking_incoterm
+#: help:account.invoice,incoterm:0
+#: help:stock.picking,incoterm:0
+#: help:stock.picking.in,incoterm:0
+#: help:stock.picking.out,incoterm:0
+msgid "International Commercial Terms are a series of predefined             commercial terms used in international transactions."
+msgstr ""
+
+#. module: stock_invoice_picking_incoterm
+#: model:ir.model,name:stock_invoice_picking_incoterm.model_account_invoice
+msgid "Invoice"
+msgstr ""
+
+#. module: stock_invoice_picking_incoterm
+#: model:ir.model,name:stock_invoice_picking_incoterm.model_stock_picking
+msgid "Picking List"
+msgstr ""
+
+#. module: stock_invoice_picking_incoterm
+#: model:ir.model,name:stock_invoice_picking_incoterm.model_stock_picking_out
+msgid "Delivery Orders"
+msgstr ""
+

=== added file 'stock_invoice_picking_incoterm/stock.py'
--- stock_invoice_picking_incoterm/stock.py	1970-01-01 00:00:00 +0000
+++ stock_invoice_picking_incoterm/stock.py	2014-04-03 09:46:52 +0000
@@ -0,0 +1,103 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2014 Agile Business Group sagl
+#    (<http://www.agilebg.com>)
+#
+#    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 openerp.osv import fields, orm
+
+
+class stock_picking(orm.Model):
+    _inherit = "stock.picking"
+
+    _columns = {
+        'incoterm': fields.many2one(
+            'stock.incoterms',
+            'Incoterm',
+            help="International Commercial Terms are a series of predefined \
+            commercial terms used in international transactions."
+        ),
+    }
+
+    def _prepare_invoice_group(
+        self, cr, uid, picking, partner, invoice, context=None
+    ):
+        invoice_vals = super(stock_picking, self)._prepare_invoice_group(
+            cr, uid, picking, partner, invoice, context)
+        if picking.incoterm:
+            invoice_vals['incoterm'] = picking.incoterm.id
+        return invoice_vals
+
+    def _prepare_invoice(
+        self, cr, uid, picking, partner, inv_type, journal_id, context=None
+    ):
+        invoice_vals = super(stock_picking, self)._prepare_invoice(
+            cr, uid, picking, partner, inv_type, journal_id, context=context)
+        if picking.incoterm:
+            invoice_vals['incoterm'] = picking.incoterm.id
+        return invoice_vals
+
+
+class stock_picking_in(orm.Model):
+    _inherit = "stock.picking.in"
+
+    _columns = {
+        'incoterm': fields.many2one(
+            'stock.incoterms',
+            'Incoterm',
+            help="International Commercial Terms are a series of predefined \
+            commercial terms used in international transactions."
+        ),
+    }
+
+    def _prepare_invoice_group(
+        self, cr, uid, picking, partner, invoice, context=None
+    ):
+        return self.pool.get('stock.picking')._prepare_invoice_group(
+            cr, uid, picking, partner, invoice, context=context)
+
+    def _prepare_invoice(
+        self, cr, uid, picking, partner, inv_type, journal_id, context=None
+    ):
+        return self.pool.get('stock.picking')._prepare_invoice(
+            cr, uid, picking, partner, inv_type, journal_id, context=context)
+
+
+class stock_picking_out(orm.Model):
+    _inherit = "stock.picking.out"
+
+    _columns = {
+        'incoterm': fields.many2one(
+            'stock.incoterms',
+            'Incoterm',
+            help="International Commercial Terms are a series of predefined \
+            commercial terms used in international transactions."
+        ),
+    }
+
+    def _prepare_invoice_group(
+        self, cr, uid, picking, partner, invoice, context=None
+    ):
+        return self.pool.get('stock.picking')._prepare_invoice_group(
+            cr, uid, picking, partner, invoice, context=context)
+
+    def _prepare_invoice(
+        self, cr, uid, picking, partner, inv_type, journal_id, context=None
+    ):
+        return self.pool.get('stock.picking')._prepare_invoice(
+            cr, uid, picking, partner, inv_type, journal_id, context=context)

=== added file 'stock_invoice_picking_incoterm/stock_view.xml'
--- stock_invoice_picking_incoterm/stock_view.xml	1970-01-01 00:00:00 +0000
+++ stock_invoice_picking_incoterm/stock_view.xml	2014-04-03 09:46:52 +0000
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+<data>
+        <record id="view_picking_out_form" model="ir.ui.view">
+            <field name="name">stock.picking.invoice.out.form</field>
+            <field name="model">stock.picking.out</field>
+            <field name="inherit_id" ref="stock.view_picking_out_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="/form/sheet/notebook/page[@string='Additional Info']/group/group/field[@name='date_done']" position="after">
+                    <field name="incoterm" widget="selection"/>
+                </xpath>
+            </field>
+        </record>
+        <record id="view_picking_in_form" model="ir.ui.view">
+            <field name="name">stock.picking.invoice.in.form</field>
+            <field name="model">stock.picking.in</field>
+            <field name="inherit_id" ref="stock.view_picking_in_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="/form/sheet/notebook/page[@string='Additional Info']/group/group/field[@name='date_done']" position="after">
+                    <field name="incoterm" widget="selection"/>
+                </xpath>
+            </field>
+        </record>
+</data>
+</openerp>

=== added directory 'stock_invoice_picking_incoterm/test'
=== added file 'stock_invoice_picking_incoterm/test/invoice_picking_incoterm.yml'
--- stock_invoice_picking_incoterm/test/invoice_picking_incoterm.yml	1970-01-01 00:00:00 +0000
+++ stock_invoice_picking_incoterm/test/invoice_picking_incoterm.yml	2014-04-03 09:46:52 +0000
@@ -0,0 +1,45 @@
+-
+  In order to test the stock_invoice_picking_incoterm module.
+  First I create an outgoing picking order
+-
+  !record {model: stock.picking, id: stock_picking_out0}:
+    partner_id: base.res_partner_address_22
+    invoice_state: 2binvoiced
+    move_lines:
+      - company_id: base.main_company
+        location_id: stock.stock_location_stock
+        product_id: product.product_product_3
+        product_qty: 3.0
+        product_uom: product.product_uom_unit
+        location_dest_id: stock.stock_location_customers
+    move_type: direct
+    type: out
+-
+  I modify the outgoing picking order and set the incoterm.
+-
+  !record {model: stock.picking, id: stock_picking_out0}:
+    incoterm: stock.incoterm_EXW
+-
+  I process the delivery
+-
+  !python {model: stock.partial.picking}: |
+    partial_id = self.create(cr, uid, {}, context={'active_model':'stock.picking',
+                                                   'active_ids':[ref('stock_picking_out0')]})
+    self.do_partial(cr, uid, [partial_id])
+
+-
+  As the invoice state of the picking order is to be invoiced. I create invoice for my outgoing picking order.
+-
+  !python {model: stock.invoice.onshipping}: |
+    wiz_id = self.create(cr, uid, {'invoice_date': '2010-08-04', 'journal_id': ref('account.sales_journal')},
+      {'active_ids': [ref("stock_picking_out0")], "active_model": "stock.picking"})
+    self.create_invoice(cr, uid, [wiz_id], {"lang": "en_US",
+      "search_default_available": 1, "tz": False, "active_model": "stock.picking",
+      "contact_display": "partner", "active_ids": [ref("stock_picking_out0")], "active_id": ref("stock_picking_out0")})
+-
+  I check that the invoice incoterm has equal to stock incoterm.
+-
+  !python {model: stock.picking}: |
+    picking = self.browse(cr, uid, ref('stock_picking_out0'))
+    assert picking.invoice_id.incoterm == picking.incoterm, 'The incoterm values are different'
+


Follow ups