Add supplier field function on moves
Add supplier and purchase field on incoming moves of packing in Add domain for supplier on incoming moves add/remove selection
This commit is contained in:
+39
@@ -1088,6 +1088,12 @@ ProductSupplierPrice()
|
||||
class PackingIn(OSV):
|
||||
_name = 'stock.packing.in'
|
||||
|
||||
def __init__(self):
|
||||
super(PackingIn, self).__init__()
|
||||
self.incoming_moves.add_remove = "[" + \
|
||||
self.incoming_moves.add_remove + ", " \
|
||||
"('supplier', '=', supplier)]"
|
||||
|
||||
def write(self, cursor, user, ids, vals, context=None):
|
||||
workflow_service = LocalService('workflow')
|
||||
purchase_line_obj = self.pool.get('purchase.line')
|
||||
@@ -1130,6 +1136,9 @@ class Move(OSV):
|
||||
purchase = fields.Function('get_purchase', type='many2one',
|
||||
relation='purchase.purchase', string='Purchase',
|
||||
fnct_search='search_purchase', select=1)
|
||||
supplier = fields.Function('get_supplier', type='many2one',
|
||||
relation='relationship.party', string='Supplier',
|
||||
fnct_search='search_supplier', select=1)
|
||||
|
||||
def get_purchase(self, cursor, user, ids, name, arg, context=None):
|
||||
purchase_obj = self.pool.get('purchase.purchase')
|
||||
@@ -1161,6 +1170,36 @@ class Move(OSV):
|
||||
i += 1
|
||||
return args2
|
||||
|
||||
def get_supplier(self, cursor, user, ids, name, arg, context=None):
|
||||
party_obj = self.pool.get('relationship.party')
|
||||
|
||||
res = {}
|
||||
for move in self.browse(cursor, user, ids, context=context):
|
||||
res[move.id] = False
|
||||
if move.purchase_line:
|
||||
res[move.id] = move.purchase_line.purchase.party.id
|
||||
|
||||
party_names = {}
|
||||
for party_id, party_name in party_obj.name_get(cursor, user,
|
||||
[x for x in res.values() if x], context=context):
|
||||
party_names[party_id] = party_name
|
||||
|
||||
for i in res.keys():
|
||||
if res[i] and res[i] in party_names:
|
||||
res[i] = (res[i], party_names[res[i]])
|
||||
else:
|
||||
res[i] = False
|
||||
return res
|
||||
|
||||
def search_supplier(self, cursor, user, name, args, context=None):
|
||||
args2 = []
|
||||
i = 0
|
||||
while i < len(args):
|
||||
args2.append(('purchase_line.purchase.party', args[i][1],
|
||||
args[i][2]))
|
||||
i += 1
|
||||
return args2
|
||||
|
||||
def write(self, cursor, user, ids, vals, context=None):
|
||||
workflow_service = LocalService('workflow')
|
||||
purchase_line_obj = self.pool.get('purchase.line')
|
||||
|
||||
@@ -731,6 +731,22 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="packing_in_view_form">
|
||||
<field name="model">stock.packing.in</field>
|
||||
<field name="inherit" ref="stock.packing_in_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<data>
|
||||
<xpath expr="/form/notebook/page/field[@name="incoming_moves"]/tree/field[@name="product"]"
|
||||
position="after">
|
||||
<field name="supplier" select="1"/>
|
||||
<field name="purchase" select="1"/>
|
||||
</xpath>
|
||||
</data>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.wizard" id="act_open_supplier">
|
||||
<field name="name">Suppliers</field>
|
||||
<field name="wiz_name">purchase.open_supplier</field>
|
||||
|
||||
Reference in New Issue
Block a user