← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~agilebg/carriers-deliveries/adding_delivery_optional_invoice_line_7 into lp:carriers-deliveries

 

Alex Comba - Agile BG has proposed merging lp:~agilebg/carriers-deliveries/adding_delivery_optional_invoice_line_7 into lp:carriers-deliveries.

Commit message:
[ADD] module delivery_optional_invoice_line

Requested reviews:
  Stock and Logistic Core Editors (stock-logistic-core-editors)

For more details, see:
https://code.launchpad.net/~agilebg/carriers-deliveries/adding_delivery_optional_invoice_line_7/+merge/213867

I added the module named 'delivery_optional_invoice_line'.

It allows to remove the default shipping line from the invoices created from picking. To do so, the user shall go to the deliver carrier form and select the option 'Do not create line on invoice'. 
-- 
https://code.launchpad.net/~agilebg/carriers-deliveries/adding_delivery_optional_invoice_line_7/+merge/213867
Your team Stock and Logistic Core Editors is requested to review the proposed merge of lp:~agilebg/carriers-deliveries/adding_delivery_optional_invoice_line_7 into lp:carriers-deliveries.
=== added directory 'delivery_optional_invoice_line'
=== added file 'delivery_optional_invoice_line/__init__.py'
--- delivery_optional_invoice_line/__init__.py	1970-01-01 00:00:00 +0000
+++ delivery_optional_invoice_line/__init__.py	2014-04-02 15:01:51 +0000
@@ -0,0 +1,21 @@
+# -*- 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 delivery

=== added file 'delivery_optional_invoice_line/__openerp__.py'
--- delivery_optional_invoice_line/__openerp__.py	1970-01-01 00:00:00 +0000
+++ delivery_optional_invoice_line/__openerp__.py	2014-04-02 15:01:51 +0000
@@ -0,0 +1,45 @@
+# -*- 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': "Delivery Optional Invoice Line",
+    'version': '0.1',
+    'category': 'Sales Management',
+    'description': """
+This module allows to remove the default shipping line from the invoices
+created from picking. To do so, the user shall go to the deliver carrier form
+and select the option 'Do not create line on invoice'.
+    """,
+    'author': 'Agile Business Group',
+    'website': 'http://www.agilebg.com',
+    'license': 'AGPL-3',
+    'depends': [
+        'delivery',
+    ],
+    'data': [
+        'delivery_view.xml',
+    ],
+    'test': [
+        'test/delivery_optional_invoice_line.yml',
+    ],
+    'active': False,
+    'installable': True
+}

=== added file 'delivery_optional_invoice_line/delivery.py'
--- delivery_optional_invoice_line/delivery.py	1970-01-01 00:00:00 +0000
+++ delivery_optional_invoice_line/delivery.py	2014-04-02 15:01:51 +0000
@@ -0,0 +1,47 @@
+# -*- 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 orm, fields
+
+
+class delivery_carrier(orm.Model):
+    _inherit = 'delivery.carrier'
+
+    _columns = {
+        'do_not_create_invoice_line': fields.boolean(
+            'Do not create line on invoice'),
+    }
+
+
+class stock_picking(orm.Model):
+    _inherit = "stock.picking"
+
+    def _prepare_shipping_invoice_line(
+        self, cr, uid, picking, invoice, context=None
+    ):
+        res = super(stock_picking, self)._prepare_shipping_invoice_line(
+            cr, uid, picking, invoice, context=context)
+        if (
+            picking.carrier_id
+            and picking.carrier_id.do_not_create_invoice_line
+        ):
+            res = None
+        return res

=== added file 'delivery_optional_invoice_line/delivery_view.xml'
--- delivery_optional_invoice_line/delivery_view.xml	1970-01-01 00:00:00 +0000
+++ delivery_optional_invoice_line/delivery_view.xml	2014-04-02 15:01:51 +0000
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <record id="view_delivery_carrier_form" model="ir.ui.view">
+            <field name="name">delivery.carrier.form</field>
+            <field name="model">delivery.carrier</field>
+            <field name="inherit_id" ref="delivery.view_delivery_carrier_form"/>
+            <field name="arch" type="xml">
+                <xpath expr="/form[@string='Carrier']/group/group/field[@name='active']" position="after">
+                        <field name="do_not_create_invoice_line"/>
+                </xpath>
+            </field>
+        </record>
+
+    </data>
+</openerp>
\ No newline at end of file

=== added directory 'delivery_optional_invoice_line/i18n'
=== added file 'delivery_optional_invoice_line/i18n/delivery_optional_invoice_line.pot'
--- delivery_optional_invoice_line/i18n/delivery_optional_invoice_line.pot	1970-01-01 00:00:00 +0000
+++ delivery_optional_invoice_line/i18n/delivery_optional_invoice_line.pot	2014-04-02 15:01:51 +0000
@@ -0,0 +1,32 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* delivery_optional_invoice_line
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-03-31 14:00+0000\n"
+"PO-Revision-Date: 2014-03-31 14:00+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: delivery_optional_invoice_line
+#: model:ir.model,name:delivery_optional_invoice_line.model_delivery_carrier
+msgid "Carrier"
+msgstr ""
+
+#. module: delivery_optional_invoice_line
+#: model:ir.model,name:delivery_optional_invoice_line.model_stock_picking
+msgid "Picking List"
+msgstr ""
+
+#. module: delivery_optional_invoice_line
+#: field:delivery.carrier,do_not_create_invoice_line:0
+msgid "Do not create invoice line"
+msgstr ""
+

=== added file 'delivery_optional_invoice_line/i18n/it.po'
--- delivery_optional_invoice_line/i18n/it.po	1970-01-01 00:00:00 +0000
+++ delivery_optional_invoice_line/i18n/it.po	2014-04-02 15:01:51 +0000
@@ -0,0 +1,32 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# 	* delivery_optional_invoice_line
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 7.0\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-03-31 14:01+0000\n"
+"PO-Revision-Date: 2014-03-31 16:07+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: delivery_optional_invoice_line
+#: model:ir.model,name:delivery_optional_invoice_line.model_delivery_carrier
+msgid "Carrier"
+msgstr "Trasportatore"
+
+#. module: delivery_optional_invoice_line
+#: model:ir.model,name:delivery_optional_invoice_line.model_stock_picking
+msgid "Picking List"
+msgstr "Picking List"
+
+#. module: delivery_optional_invoice_line
+#: field:delivery.carrier,do_not_create_invoice_line:0
+msgid "Do not create invoice line"
+msgstr "Non creare riga di fattura"

=== added directory 'delivery_optional_invoice_line/test'
=== added file 'delivery_optional_invoice_line/test/delivery_optional_invoice_line.yml'
--- delivery_optional_invoice_line/test/delivery_optional_invoice_line.yml	1970-01-01 00:00:00 +0000
+++ delivery_optional_invoice_line/test/delivery_optional_invoice_line.yml	2014-04-02 15:01:51 +0000
@@ -0,0 +1,50 @@
+
+-
+  In order to test process of the Delivery Optional Invoice Line,
+- 
+  I set the do_not_create_invoice_line field as True on the free_delivery_carrier.
+-  
+  !record {model: delivery.carrier, id: delivery.free_delivery_carrier}:
+    do_not_create_invoice_line: True
+-
+  I create sale order having picking as order_policy and free_delivery_carrier as carrier_id.
+-
+  !record {model: sale.order, id: sale_order_test}:
+    partner_id: base.res_partner_2
+    order_policy: picking
+    carrier_id: delivery.free_delivery_carrier
+    order_line: 
+      - product_id: product.product_product_7
+        product_uom_qty: 8
+-
+  I confirm sale order.
+-
+  !workflow {model: sale.order, action: order_confirm, ref: sale_order_test}
+-
+  Now, I dispatch delivery order.
+-
+  !python {model: stock.partial.picking}: |
+    order = self.pool.get('sale.order').browse(cr, uid, ref("sale_order_test"))
+    for pick in order.picking_ids:
+        data = pick.force_assign()
+        if data == True:
+          partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick.id]})
+          self.do_partial(cr, uid, [partial_id])
+-
+  I create invoice from delivery order.
+-
+  !python {model: stock.invoice.onshipping}: |
+    sale = self.pool.get('sale.order')
+    sale_order = sale.browse(cr, uid, ref("sale_order_test"))
+    ship_ids = [x.id for x in sale_order.picking_ids]
+    wiz_id = self.create(cr, uid, {'journal_id': ref('account.sales_journal')},
+      {'active_ids': ship_ids, 'active_model': 'stock.picking'})
+    self.create_invoice(cr, uid, [wiz_id], {"active_ids": ship_ids, "active_id": ship_ids[0]})
+-
+  I check the invoice details after dispatched delivery.
+-
+  !python {model: sale.order}: |
+    order = self.browse(cr, uid, ref("sale_order_test"))
+    assert order.invoice_ids, "Invoice is not created."
+    for invoice in order.invoice_ids:
+    	assert len(invoice.invoice_line) == len(order.order_line), "Lines of Invoice and Sale Order are not correspond"


Follow ups