-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new addon framework_agreement_sourcing_stock_route_transit
- Loading branch information
1 parent
c28863f
commit 93ddb1f
Showing
9 changed files
with
308 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
framework_agreement_sourcing_stock_route_transit/README.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Framework Agreement Sourcing with Transit management | ||
==================================================== | ||
|
||
This module ensures that the framework agreement sourcing purchases made in | ||
dropshipping mode will go through the transit locations when | ||
`stock_route_transit` (from https://github.com/OCA/stock-logistics-workflow/) | ||
is installed. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Alexandre Fayolle <alexandre.fayolle@camptocamp.com> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: http://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: http://odoo-community.org | ||
|
||
This module is maintained by the OCA. | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. | ||
|
||
To contribute to this module, please visit http://odoo-community.org. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import model |
37 changes: 37 additions & 0 deletions
37
framework_agreement_sourcing_stock_route_transit/__openerp__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: Alexandre Fayolle | ||
# Copyright 2015 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 <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
{'name': 'Sourcing for Framework Agreement with Transit routes', | ||
'version': '0.1', | ||
'author': 'Camptocamp', | ||
'maintainer': 'Camptocamp', | ||
'category': 'NGO', | ||
'complexity': 'normal', | ||
'depends': ['framework_agreement_sourcing', 'stock_route_transit'], | ||
'website': 'http://www.camptocamp.com', | ||
'data': [ | ||
], | ||
'demo': [], | ||
'test': [], | ||
'installable': True, | ||
'auto_install': True, | ||
'license': 'AGPL-3', | ||
'application': False, | ||
} |
1 change: 1 addition & 0 deletions
1
framework_agreement_sourcing_stock_route_transit/model/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import logistic_requisition_source |
40 changes: 40 additions & 0 deletions
40
framework_agreement_sourcing_stock_route_transit/model/logistic_requisition_source.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: Nicolas Bessi | ||
# Copyright 2013-2015 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 <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
|
||
from openerp.osv import orm | ||
|
||
class LogisticRequisitionSource(orm.Model): | ||
_inherit = "logistic.requisition.source" | ||
|
||
def _prepare_purchase_order(self, cr, uid, | ||
line, po_pricelist, context=None): | ||
"""change the destination location and route | ||
of the generated purchase order""" | ||
_super = super(LogisticRequisitionSource, self) | ||
res = _super._prepare_purchase_order(cr, uid, | ||
line, po_pricelist, | ||
context=context) | ||
ref = IrModelData = self.pool['ir.model.data'].xmlid_to_res_id | ||
transit_location_id = ref(cr, uid, 'stock_route_transit.transit_outgoing') | ||
res['location_id'] = transit_location_id | ||
pick_type_id = ref(cr, uid, 'stock_dropshipping.picking_type_dropship') | ||
res['picking_type_id'] = pick_type_id | ||
return res |
36 changes: 36 additions & 0 deletions
36
framework_agreement_sourcing_stock_route_transit/model/logistic_requisition_source.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: Nicolas Bessi | ||
# Copyright 2013-2015 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 <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
|
||
from openerp import models, api | ||
|
||
class LogisticRequisitionSource(models.Model): | ||
_inherit = "logistic.requisition.source" | ||
|
||
def _prepare_purchase_order(self, line, po_pricelist): | ||
"""change the destination location and route | ||
of the generated purchase order""" | ||
_super = super(LogisticRequisitionSource, self) | ||
res = _super._prepare_purchase_order(line, po_pricelist) | ||
transit_location = self.env.ref('stock_route_transit.transit_outgoing') | ||
res['location_id'] = transit_location.id | ||
pick_type = self.env.ref('stock_dropshipping.picking_type_dropship') | ||
res['picking_type_id'] = pick_type.id | ||
return res |
1 change: 1 addition & 0 deletions
1
framework_agreement_sourcing_stock_route_transit/tests/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_agreement_source_line_to_po |
160 changes: 160 additions & 0 deletions
160
framework_agreement_sourcing_stock_route_transit/tests/test_agreement_source_line_to_po.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# -*- coding: utf-8 -*- | ||
############################################################################## | ||
# | ||
# Author: Nicolas Bessi | ||
# Copyright 2013-2015 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 <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
import openerp.addons.framework_agreement_sourcing.tests as fa_sourcing_test | ||
|
||
base_test = fa_sourcing_test.test_agreement_source_line_to_po | ||
|
||
class TestSourceToPoTransit(base_test.TestSourceToPo): | ||
|
||
def setUp(self): | ||
# we generate a source line | ||
super(TestSourceToPoTransit, self).setUp() | ||
StockWarehouse = self.env['stock.warehouse'] | ||
warehouse_id = self.ref('stock.warehouse0') | ||
warehouse = StockWarehouse.browse(warehouse_id) | ||
warehouse.write({'reception_steps': 'transit_three_steps', | ||
'delivery_steps': 'pick_pack_ship_transit'}) | ||
|
||
def test_01_transform_source_to_agreement_wh_dest(self): | ||
"""Test transformation of an LRS sourced by FA to PO delivering to WH""" | ||
cr, uid = self.cr, self.uid | ||
|
||
# Set destination address | ||
partner_vals = { | ||
'name': 'Warehouse address', | ||
} | ||
partner_wh = self.env['res.partner'].create(partner_vals) | ||
warehouse_id = self.ref('stock.warehouse0') | ||
warehouse = self.env['stock.warehouse'].browse(warehouse_id) | ||
warehouse.partner_id = partner_wh | ||
picking_type_wh = warehouse.transit_in_type_id | ||
self.agr_line.consignee_shipping_id = partner_wh | ||
|
||
self.assertTrue(self.lta_source, 'no lta source found') | ||
self.lta_source.refresh() | ||
active_ids = [x.id for x in self.source_lines] | ||
wiz_ctx = {'active_model': 'logistic.requisition.source', | ||
'active_ids': active_ids} | ||
wiz_id = self.wiz_model.create(self.cr, self.uid, {}, | ||
context=wiz_ctx) | ||
|
||
po_id = self.wiz_model.action_create_agreement_po_requisition( | ||
cr, uid, [wiz_id], context=wiz_ctx)['res_id'] | ||
self.assertTrue(po_id, "no PO created") | ||
supplier = self.lta_source.framework_agreement_id.supplier_id | ||
add = self.lta_source.requisition_id.consignee_shipping_id | ||
consignee = self.lta_source.requisition_id.consignee_id | ||
po = self.registry('purchase.order').browse(cr, uid, po_id) | ||
date_order = self.lta_source.requisition_id.date | ||
date_delivery = self.lta_source.requisition_id.date_delivery | ||
self.assertEqual(po.partner_id, supplier) | ||
self.assertEqual( | ||
po.pricelist_id, supplier.property_product_pricelist_purchase) | ||
self.assertEqual(po.date_order, date_order) | ||
self.assertEqual(po.dest_address_id, add) | ||
self.assertEqual(po.picking_type_id.id, picking_type_wh) | ||
self.assertEqual(po.consignee_id, consignee) | ||
self.assertEqual(po.state, 'draftpo') | ||
self.assertNotEqual(po.name, self.requisition.name) | ||
self.assertEqual(len(po.order_line), 2) | ||
|
||
po_line = next(x for x in po.order_line | ||
if x.product_id == | ||
self.lta_source.framework_agreement_id.product_id) | ||
self.assertEqual(po_line.product_qty, self.lta_source.proposed_qty) | ||
self.assertEqual( | ||
po_line.product_id, self.lta_source.proposed_product_id) | ||
self.assertEqual(po_line.product_qty, self.lta_source.proposed_qty) | ||
self.assertEqual(po_line.product_uom, self.lta_source.proposed_uom_id) | ||
self.assertAlmostEqual(po_line.price_unit, 50.0) | ||
self.assertEqual(po_line.lr_source_line_id, self.lta_source) | ||
self.assertEqual(po_line.date_planned, date_delivery) | ||
|
||
po_line = next(x for x in po.order_line | ||
if x.product_id == | ||
self.other_source.proposed_product_id) | ||
self.assertEqual(po_line.product_qty, self.other_source.proposed_qty) | ||
self.assertEqual( | ||
po_line.product_id, self.other_source.proposed_product_id) | ||
self.assertEqual(po_line.product_qty, self.other_source.proposed_qty) | ||
self.assertEqual( | ||
po_line.product_uom, self.other_source.proposed_uom_id) | ||
self.assertAlmostEqual(po_line.price_unit, 1.0) | ||
self.assertEqual(po_line.lr_source_line_id, self.other_source) | ||
|
||
def test_02_transform_source_to_agreement_dropshipping(self): | ||
"""Test transformation of an LRS sourced by FA to PO dropshipping""" | ||
cr, uid = self.cr, self.uid | ||
|
||
# Set destination address | ||
partner_dropship = self.ref('base.res_partner_12') | ||
self.agr_line.consignee_shipping_id = partner_dropship | ||
|
||
self.assertTrue(self.lta_source, 'no lta source found') | ||
self.lta_source.refresh() | ||
active_ids = [x.id for x in self.source_lines] | ||
wiz_ctx = {'active_model': 'logistic.requisition.source', | ||
'active_ids': active_ids} | ||
wiz_id = self.wiz_model.create(self.cr, self.uid, {}, context=wiz_ctx) | ||
|
||
po_id = self.wiz_model.action_create_agreement_po_requisition( | ||
cr, uid, [wiz_id], context=wiz_ctx)['res_id'] | ||
self.assertTrue(po_id, "no PO created") | ||
supplier = self.lta_source.framework_agreement_id.supplier_id | ||
add = self.lta_source.requisition_id.consignee_shipping_id | ||
consignee = self.lta_source.requisition_id.consignee_id | ||
po = self.registry('purchase.order').browse(cr, uid, po_id) | ||
date_order = self.lta_source.requisition_id.date | ||
date_delivery = self.lta_source.requisition_id.date_delivery | ||
self.assertEqual(po.partner_id, supplier) | ||
self.assertEqual( | ||
po.pricelist_id, supplier.property_product_pricelist_purchase) | ||
self.assertEqual(po.date_order, date_order) | ||
self.assertEqual(po.dest_address_id, add) | ||
self.assertEqual(po.picking_type_id.name, 'Dropship') | ||
self.assertEqual(po.consignee_id, consignee) | ||
self.assertEqual(po.state, 'draftpo') | ||
self.assertNotEqual(po.name, self.requisition.name) | ||
self.assertEqual(len(po.order_line), 2) | ||
|
||
po_line = next(x for x in po.order_line | ||
if x.product_id == | ||
self.lta_source.framework_agreement_id.product_id) | ||
self.assertEqual(po_line.product_qty, self.lta_source.proposed_qty) | ||
self.assertEqual( | ||
po_line.product_id, self.lta_source.proposed_product_id) | ||
self.assertEqual(po_line.product_qty, self.lta_source.proposed_qty) | ||
self.assertEqual(po_line.product_uom, self.lta_source.proposed_uom_id) | ||
self.assertAlmostEqual(po_line.price_unit, 50.0) | ||
self.assertEqual(po_line.lr_source_line_id, self.lta_source) | ||
self.assertEqual(po_line.date_planned, date_delivery) | ||
|
||
po_line = next(x for x in po.order_line | ||
if x.product_id == | ||
self.other_source.proposed_product_id) | ||
self.assertEqual(po_line.product_qty, self.other_source.proposed_qty) | ||
self.assertEqual( | ||
po_line.product_id, self.other_source.proposed_product_id) | ||
self.assertEqual(po_line.product_qty, self.other_source.proposed_qty) | ||
self.assertEqual( | ||
po_line.product_uom, self.other_source.proposed_uom_id) | ||
self.assertAlmostEqual(po_line.price_unit, 1.0) | ||
self.assertEqual(po_line.lr_source_line_id, self.other_source) |