[MOV] stock: Move stock part from warning module
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.addons.base.res.res_partner import WARNING_MESSAGE, WARNING_HELP
|
||||
|
||||
class res_partner(osv.osv):
|
||||
_inherit = 'res.partner'
|
||||
@@ -16,4 +17,10 @@ class res_partner(osv.osv):
|
||||
relation='stock.location',
|
||||
string="Vendor Location",
|
||||
help="This stock location will be used, instead of the default one, as the source location for goods you receive from the current partner"),
|
||||
'picking_warn' : fields.selection(WARNING_MESSAGE, 'Stock Picking', help=WARNING_HELP, required=True),
|
||||
'picking_warn_msg' : fields.text('Message for Stock Picking'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'picking_warn': 'no-message',
|
||||
}
|
||||
|
||||
@@ -21,5 +21,21 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_partner_stock_warnings_form" model="ir.ui.view">
|
||||
<field name="name">res.partner.stock.warning</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="inherit_id" ref="base.view_partner_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<page name="warnings" position="inside">
|
||||
<group colspan="2" col="2">
|
||||
<separator string="Warning on the Picking" colspan="4"/>
|
||||
<field name="picking_warn" nolabel="1" />
|
||||
<field name="picking_warn_msg" colspan="3" nolabel="1"
|
||||
attrs="{'required':[('picking_warn','!=','no-message')],'readonly':[('picking_warn','=','no-message')]}"/>
|
||||
</group>
|
||||
</page>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
+28
-1
@@ -914,9 +914,36 @@ class stock_picking(models.Model):
|
||||
location_dest_id = picking_type.default_location_dest_id.id
|
||||
|
||||
res['value'] = {'location_id': location_id,
|
||||
'location_dest_id': location_dest_id,}
|
||||
'location_dest_id': location_dest_id}
|
||||
|
||||
if partner_id:
|
||||
warning = {}
|
||||
title = False
|
||||
message = False
|
||||
partner = self.pool['res.partner'].browse(cr, uid, partner_id, context=context)
|
||||
|
||||
# If partner has no warning, check its company
|
||||
if partner.picking_warn == 'no-message' and partner.parent_id:
|
||||
partner = partner.parent_id
|
||||
|
||||
if partner.picking_warn != 'no-message':
|
||||
# Block if partner only has warning but parent company is blocked
|
||||
if partner.picking_warn != 'block' and partner.parent_id and partner.parent_id.picking_warn == 'block':
|
||||
partner = partner.parent_id
|
||||
title = _("Warning for %s") % partner.name
|
||||
message = partner.picking_warn_msg
|
||||
warning = {
|
||||
'title': title,
|
||||
'message': message
|
||||
}
|
||||
if partner.picking_warn == 'block':
|
||||
return {'value': {'partner_id': False}, 'warning': warning}
|
||||
return {'warning': warning}
|
||||
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def _default_location_destination(self):
|
||||
# retrieve picking type from context; if none this returns an empty recordset
|
||||
picking_type_id = self._context.get('default_picking_type_id')
|
||||
|
||||
Reference in New Issue
Block a user