Add module stock_picking_type_default_partner
This commit is contained in:
3
stock_picking_type_default_partner/__init__.py
Normal file
3
stock_picking_type_default_partner/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from . import stock
|
||||
45
stock_picking_type_default_partner/__openerp__.py
Normal file
45
stock_picking_type_default_partner/__openerp__.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Stock Picking Type Default Partner module for Odoo
|
||||
# Copyright (C) 2014 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# 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': 'Stock Picking Type Default Partner',
|
||||
'version': '0.1',
|
||||
'category': 'Inventory, Logistic, Storage',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Adds a default partner on types of operation',
|
||||
'description': """
|
||||
Stock Picking Type Default Partner
|
||||
==================================
|
||||
|
||||
This module adds a new field on the Types of Operation (stock.picking.type) : *Default Partner*.
|
||||
|
||||
This module has been written by Alexis de Lattre from Akretion <alexis.delattre@akretion.com>.
|
||||
""",
|
||||
'author': 'Akretion',
|
||||
'website': 'http://www.akretion.com',
|
||||
'depends': ['stock'],
|
||||
'data': [
|
||||
'stock_view.xml'
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
57
stock_picking_type_default_partner/stock.py
Normal file
57
stock_picking_type_default_partner/stock.py
Normal file
@@ -0,0 +1,57 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# Stock Picking Type Default Partner module for Odoo
|
||||
# Copyright (C) 2014 Akretion (http://www.akretion.com)
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
#
|
||||
# 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# For an unknown reasons, it doesn't work when using the new API
|
||||
# with this module it breaks in an SQL query trying to select the
|
||||
# "picking_type_code" on stock.picking although it is a related field
|
||||
# store=False So I keep it with the old API for the moment
|
||||
from openerp.osv import orm, fields
|
||||
|
||||
|
||||
class StockPickingType(orm.Model):
|
||||
_inherit = 'stock.picking.type'
|
||||
|
||||
_columns = {
|
||||
'default_partner_id': fields.many2one(
|
||||
'res.partner', 'Default Partner', ondelete='restrict',
|
||||
help="If set, it will be the default partner on this type "
|
||||
"of pickings."),
|
||||
}
|
||||
|
||||
|
||||
class StockPicking(orm.Model):
|
||||
_inherit = 'stock.picking'
|
||||
|
||||
def _default_partner_id(self, cr, uid, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if context.get('default_picking_type_id'):
|
||||
picktype = self.pool['stock.picking.type'].browse(
|
||||
cr, uid, context.get('default_picking_type_id'),
|
||||
context=context)
|
||||
if picktype.default_partner_id:
|
||||
return picktype.default_partner_id.id
|
||||
return False
|
||||
|
||||
_defaults = {
|
||||
'partner_id': _default_partner_id,
|
||||
}
|
||||
24
stock_picking_type_default_partner/stock_view.xml
Normal file
24
stock_picking_type_default_partner/stock_view.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2015 Akretion (http://www.akretion.com/)
|
||||
@author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
The licence is in the file __openerp__.py
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="view_picking_type_form" model="ir.ui.view">
|
||||
<field name="name">default.partner.stock.picking.type.form</field>
|
||||
<field name="model">stock.picking.type</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_type_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="default_location_dest_id" position="after">
|
||||
<field name="default_partner_id"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user