From 7bdd4de8051afa11e3941f7ab930c96b2e82bbc7 Mon Sep 17 00:00:00 2001 From: qdp-odoo Date: Fri, 2 Sep 2016 14:10:44 +0200 Subject: [PATCH] [FIX] anglo_saxon_dropshipping: fix dropship use case in anglo saxon with perpetual valuation. OPW: 684742 When using dropship+anglo-saxon+perpetual valuation, there is no journal move for the delivery to debit outgoing inventory (since the goods don't transit by an internal stock) but the sale does credit it so there was a build up in the holding account that has to be moved out manually. This was also reported in #12687. The solution implemented is to check if the invoice line is related to sale order lines having one of its procurement_ids with a purchase_line_id set. If yes, it means that it is a confirmed dropship and in that case we don't call to super (we don't create the cost of sale line). That means that: * If the procurement is in exception at the customer invoice time, the behavior will be as it is currently, but it's fine as you don't know how the procurement will be solved, and it'll be only at the beginning (once the config is done it shouldn't go in exception anymore). People will have to manually fix those amounts with a miscellaneous operation. * users in anglo saxon mode should not use the 'stock interim account (received)' on supplier invoices for dropshipped goods, but rather use the COGS directly (sounds to me logical, and that's actually why I wouldn't go for the solution to create the stock move entries every time even for the dropshipped goods. That, and the fact that it would pollute the accounting with useless moves) --- addons/anglo_saxon_dropshipping/__init__.py | 23 +++++++++++ .../anglo_saxon_dropshipping/__openerp__.py | 38 +++++++++++++++++++ .../stock_dropshipping.py | 15 ++++++++ 3 files changed, 76 insertions(+) create mode 100644 addons/anglo_saxon_dropshipping/__init__.py create mode 100644 addons/anglo_saxon_dropshipping/__openerp__.py create mode 100644 addons/anglo_saxon_dropshipping/stock_dropshipping.py diff --git a/addons/anglo_saxon_dropshipping/__init__.py b/addons/anglo_saxon_dropshipping/__init__.py new file mode 100644 index 00000000000..2425d5b7bfe --- /dev/null +++ b/addons/anglo_saxon_dropshipping/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# 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 . +# +############################################################################## +import stock_dropshipping + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/anglo_saxon_dropshipping/__openerp__.py b/addons/anglo_saxon_dropshipping/__openerp__.py new file mode 100644 index 00000000000..bf3861c11b1 --- /dev/null +++ b/addons/anglo_saxon_dropshipping/__openerp__.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2014 OpenERP S.A. (). +# +# 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 . +# +############################################################################## + +{ + 'name': 'Drop Shipping anglosaxon', + 'version': '1.0', + 'category': 'Warehouse Management', + 'summary': 'Drop Shipping in anglo-saxon', + 'description': """ + +""", + 'author': 'OpenERP SA', + 'website': 'https://www.odoo.com/page/warehouse', + 'depends': ['account_anglo_saxon', 'stock_dropshipping'], + 'test': [ + ], + 'installable': True, + 'auto_install': True, +} +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/anglo_saxon_dropshipping/stock_dropshipping.py b/addons/anglo_saxon_dropshipping/stock_dropshipping.py new file mode 100644 index 00000000000..99d05fa0232 --- /dev/null +++ b/addons/anglo_saxon_dropshipping/stock_dropshipping.py @@ -0,0 +1,15 @@ +# coding: utf-8 + +from openerp.osv import osv + +class account_invoice_line(osv.osv): + _inherit = 'account.invoice.line' + + def _anglo_saxon_sale_move_lines(self, cr, uid, i_line, res, context=None): + salelines = self.pool.get('sale.order.line').search(cr, uid, [('invoice_lines', 'in', [i_line.id])]) + for sale_line in self.pool.get('sale.order.line').browse(cr, uid, salelines, context=context): + for proc in sale_line.procurement_ids: + if proc.purchase_line_id: + #if the invoice line is related to sale order lines having one of its procurement_ids with a purchase_line_id set, it means that it is a confirmed dropship and in that case we mustn't create the cost of sale line (because the product won't enter the stock) + return [] + return super(account_invoice_line, self)._anglo_saxon_sale_move_lines(cr, uid, i_line, res, context=context)