Skip to content

Commit

Permalink
Merge 93ddb1f into fb21da6
Browse files Browse the repository at this point in the history
  • Loading branch information
gurneyalex committed Feb 26, 2015
2 parents fb21da6 + 93ddb1f commit ffd40f7
Show file tree
Hide file tree
Showing 11 changed files with 310 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ python:

env:
- VERSION="8.0" LINT_CHECK="1"
- VERSION="8.0" ODOO_REPO="odoo/odoo" EXCLUDE="logistic_consignee" LINT_CHECK="0"
- VERSION="8.0" ODOO_REPO="OCA/OCB" EXCLUDE="logistic_consignee" LINT_CHECK="0"
- VERSION="8.0" ODOO_REPO="odoo/odoo" EXCLUDE="logistic_consignee,framework_agreement_sourcing_stock_route_transit" LINT_CHECK="0"
- VERSION="8.0" ODOO_REPO="OCA/OCB" EXCLUDE="logistic_consignee,framework_agreement_sourcing_stock_route_transit" LINT_CHECK="0"
- VERSION="8.0" ODOO_REPO="odoo/odoo" INCLUDE="framework_agreement_sourcing_stock_route_transit" LINT_CHECK="0"
- VERSION="8.0" ODOO_REPO="OCA/OCB" INCLUDE="framework_agreement_sourcing_stock_route_transit" LINT_CHECK="0"
- VERSION="8.0" ODOO_REPO="odoo/odoo" INCLUDE="logistic_consignee" LINT_CHECK="0"
- VERSION="8.0" ODOO_REPO="OCA/OCB" INCLUDE="logistic_consignee" LINT_CHECK="0"

Expand Down
3 changes: 1 addition & 2 deletions framework_agreement_sourcing/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#
# 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 common
from . import test_logistic_order_line_to_source_line
from . import test_agreement_souce_line_to_po
from . import test_agreement_source_line_to_po
from . import test_check_sourcing
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_01_transform_source_to_agreement_wh_dest(self):
self.assertAlmostEqual(po_line.price_unit, 1.0)
self.assertEqual(po_line.lr_source_line_id, self.other_source)

def test_01_transform_source_to_agreement_dropshipping(self):
def test_02_transform_source_to_agreement_dropshipping(self):
"""Test transformation of an agreement source line into PO"""
cr, uid = self.cr, self.uid

Expand Down
28 changes: 28 additions & 0 deletions framework_agreement_sourcing_stock_route_transit/README.rst
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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import model
37 changes: 37 additions & 0 deletions framework_agreement_sourcing_stock_route_transit/__openerp__.py
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,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import logistic_requisition_source
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
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_agreement_source_line_to_po
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)

0 comments on commit ffd40f7

Please sign in to comment.