-
-
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.
Merge pull request #14 from yvaucher/8.0-add-logistic_consignee
add module logistic_consignee
- Loading branch information
Showing
28 changed files
with
653 additions
and
44 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
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,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> |
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,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import model |
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,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, | ||
} |
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,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 "" | ||
|
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,7 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import purchase_order | ||
from . import purchase_requisition | ||
from . import sale_order | ||
from . import stock_move | ||
from . import stock_picking |
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,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 |
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,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 |
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,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') |
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,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 |
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,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.") |
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,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) |
Oops, something went wrong.