Skip to content

Commit

Permalink
Merge e8c0e05 into 01f8593
Browse files Browse the repository at this point in the history
  • Loading branch information
yvaucher committed Oct 31, 2014
2 parents 01f8593 + e8c0e05 commit ba7e969
Show file tree
Hide file tree
Showing 28 changed files with 652 additions and 44 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ python:
- "2.7"

env:
- VERSION="8.0" ODOO_REPO="odoo/odoo"
- VERSION="8.0" ODOO_REPO="OCA/OCB"
- VERSION="8.0" ODOO_REPO="odoo/odoo" EXCLUDE="logistic_consignee,logistic_requisition,logistic_order"
- VERSION="8.0" ODOO_REPO="OCA/OCB" EXCLUDE="logistic_consignee,logistic_requisition,logistic_order"
- VERSION="8.0" ODOO_REPO="odoo/odoo" INCLUDE="logistic_consignee,logistic_order,logistic_consignee"
- VERSION="8.0" ODOO_REPO="OCA/OCB" INCLUDE="logistic_consignee,logistic_order,logistic_consignee"

virtualenv:
system_site_packages: true
Expand Down
13 changes: 13 additions & 0 deletions logistic_consignee/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Logistic Consignee
==================

This module adds a consignee, the person to whom the shipment must
be delivered, on Sale Orders, Purchase Orders and Purchase Requisition.

This info will be transferred to stock picking on document validation.


Contributors
------------

* Yannick Vaucher <yannick.vaucher@camptocamp.com>
3 changes: 3 additions & 0 deletions logistic_consignee/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import model
45 changes: 45 additions & 0 deletions logistic_consignee/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
#
#
# Author: Yannick Vaucher
# Copyright 2014 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": "Logistic Consignee",
"summary": "Consignee on Sales, Purchases, Purchase requisition for Pickings",
"version": "0.1",
"author": "Camptocamp",
"license": "AGPL-3",
"category": "Logistics",
'complexity': "normal",
"images": [],
"website": "http://www.camptocamp.com",
"depends": ["sale_stock",
"purchase",
"purchase_requisition",
],
"demo": [],
"data": ['view/purchase_order.xml',
'view/purchase_requisition.xml',
'view/sale_order.xml',
'view/stock_picking.xml',
'view/report_saleorder.xml',
],
"test": ['test/test_report.yml'],
'installable': True,
"auto_install": False,
}
62 changes: 62 additions & 0 deletions logistic_consignee/i18n/logistic_consignee.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * logistic_consignee
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-10-30 16:00+0000\n"
"PO-Revision-Date: 2014-10-30 16: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: logistic_consignee
#: field:purchase.order,consignee_id:0
#: field:purchase.requisition,consignee_id:0
#: field:sale.order,consignee_id:0
#: field:stock.picking,consignee_id:0
msgid "Consignee"
msgstr ""

#. module: logistic_consignee
#: help:purchase.requisition,consignee_id:0
msgid "Person responsible of delivery"
msgstr ""

#. module: logistic_consignee
#: model:ir.model,name:logistic_consignee.model_stock_picking
msgid "Picking List"
msgstr ""

#. module: logistic_consignee
#: model:ir.model,name:logistic_consignee.model_purchase_order
msgid "Purchase Order"
msgstr ""

#. module: logistic_consignee
#: model:ir.model,name:logistic_consignee.model_purchase_requisition
msgid "Purchase Requisition"
msgstr ""

#. module: logistic_consignee
#: model:ir.model,name:logistic_consignee.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: logistic_consignee
#: model:ir.model,name:logistic_consignee.model_stock_move
msgid "Stock Move"
msgstr ""

#. module: logistic_consignee
#: help:purchase.order,consignee_id:0
#: help:sale.order,consignee_id:0
#: help:stock.picking,consignee_id:0
msgid "The person to whom the shipment is to be delivered."
msgstr ""

7 changes: 7 additions & 0 deletions logistic_consignee/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-

from . import purchase_order
from . import purchase_requisition
from . import sale_order
from . import stock_move
from . import stock_picking
38 changes: 38 additions & 0 deletions logistic_consignee/model/purchase_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
#
#
# Author: Yannick Vaucher
# Copyright 2014 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, fields, api


class PurchaseOrder(models.Model):
_inherit = "purchase.order"

consignee_id = fields.Many2one(
'res.partner', 'Consignee',
help="The person to whom the shipment is to be delivered.")

@api.multi
def action_picking_create(self):
""" Propagate value of consignee_id to the created picking """
res = super(PurchaseOrder, self).action_picking_create()

for order in self:
order.picking_ids.write({'consignee_id': order.consignee_id.id})
return res
38 changes: 38 additions & 0 deletions logistic_consignee/model/purchase_requisition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
#
#
# Author: Yannick Vaucher
# Copyright 2014 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, fields, api


class PurchaseRequisition(models.Model):
_inherit = "purchase.requisition"
_description = "Call for Bids"

consignee_id = fields.Many2one(
'res.partner',
'Consignee',
help="The person to whom the shipment is to be delivered.")

@api.model
def _prepare_purchase_order(self, requisition, supplier):
values = super(PurchaseRequisition, self
)._prepare_purchase_order(requisition, supplier)
values['consignee_id'] = requisition.consignee_id.id
return values
45 changes: 45 additions & 0 deletions logistic_consignee/model/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
#
#
# Author: Yannick Vaucher
# Copyright 2014 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, fields, api
from openerp import SUPERUSER_ID


class SaleOrder(models.Model):
_inherit = 'sale.order'

consignee_id = fields.Many2one(
'res.partner',
string='Consignee',
required=True,
help="The person to whom the shipment is to be delivered.")

@api.cr
def init(self, cr):
"""set SUPERUSER_ID as consignee_id for existing sale orders
"""
cr.execute('SELECT COUNT(id) FROM sale_order'
' WHERE consignee_id IS NULL')
count = cr.fetchone()[0]
if count:
cr.execute('UPDATE sale_order SET consignee_id=%s'
' WHERE consignee_id IS NULL', (SUPERUSER_ID,))
cr.execute('ALTER TABLE sale_order ALTER COLUMN consignee_id'
' SET NOT NULL')
46 changes: 46 additions & 0 deletions logistic_consignee/model/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
#
#
# Author: Yannick Vaucher
# Copyright 2014 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 StockMove(models.Model):
_inherit = "stock.move"

@api.cr_uid_ids_context
def _picking_assign(self, cr, uid, move_ids, procurement_group,
location_from, location_to, context=None):
res = super(StockMove, self
)._picking_assign(cr, uid, move_ids, procurement_group,
location_from, location_to,
context=context)
pick_ids = self.pool['stock.picking'].search(
cr, uid, [
('group_id', '=', procurement_group),
('location_id', '=', location_from),
('location_dest_id', '=', location_to),
('state', 'in', ['draft', 'confirmed', 'waiting'])])
if pick_ids:
pick_id = pick_ids[0]
pick = self.pool['stock.picking'].browse(cr, uid, pick_id,
context=context)
if pick.sale_id and not pick.consignee_id:
pick.write({'consignee_id': pick.sale_id.consignee_id.id})
return res
29 changes: 29 additions & 0 deletions logistic_consignee/model/stock_picking.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
#
#
# Author: Yannick Vaucher
# Copyright 2014 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, fields


class StockPicking(models.Model):
_inherit = "stock.picking"

consignee_id = fields.Many2one(
'res.partner', 'Consignee',
help="The person to whom the shipment is to be delivered.")
49 changes: 49 additions & 0 deletions logistic_consignee/test/test_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
-
I order to see that webkit report is not broken I run a test report
-
I create a new firesteel product for my test
-
!record {model: product.product, id: product_firesteel}:
categ_id: product.product_category_1
name: Firesteel
type: product
uom_id: product.product_uom_unit
uom_po_id: product.product_uom_unit
property_stock_inventory: stock.location_inventory
property_stock_procurement: stock.location_procurement
property_stock_production: stock.location_production
-
I create a logistic order
-
!record {model: sale.order, id: so_0}:
client_order_ref: ref firesteel 0
date_order: !eval time.strftime('%Y-03-30')
name: 30th of March
order_line:
- name: Firesteel
price_unit: 0.20
product_uom: product.product_uom_unit
product_uom_qty: 10000
state: draft
delay: 7.0
product_id: product_firesteel
product_uos_qty: 10000
order_policy: manual
partner_id: base.res_partner_4
partner_invoice_id: base.res_partner_address_7
partner_shipping_id: base.res_partner_address_7
picking_policy: direct
pricelist_id: product.list0
consignee_id: base.res_partner_address_4
-
I print the report
-
!python {model: sale.order}: |
import os
import openerp.report
from openerp import tools
data, format = openerp.report.render_report(cr, uid, [ref('so_0')], 'sale.report_saleorder', {}, {})
if tools.config['test_report_directory']:
path = os.path.join(tools.config['test_report_directory'], 'logistic_order-report.%s' % format)
with open(path, 'wb+') as fobj:
fobj.write(data)
Loading

0 comments on commit ba7e969

Please sign in to comment.