1
=== modificado archivo sale_mrp/sale_mrp.py
2
--- sale_mrp/sale_mrp.py 2011-06-09 18:24:44 +0000
3
+++ sale_mrp/sale_mrp.py 2011-10-16 20:34:22 +0000
5
class mrp_production(osv.osv):
6
_inherit = 'mrp.production'
8
- def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context=None):
9
+ def _get_sale_ref(self, cr, uid, ids, field_names=None, arg=False, context=None):
10
""" Finds reference of sales order for production order.
11
@param field_names: Names of fields.
12
@param arg: User defined arguments
13
@return: Dictionary of values.
19
- res[id] = {}.fromkeys(field_names, False)
20
- for f in field_names:
22
- if f == 'sale_name':
25
- field_name = 'client_order_ref'
26
- for key, value in self._get_sale_ref(cr, uid, ids, field_name).items():
30
- def _get_sale_ref(self, cr, uid, ids, field_name=False):
31
move_obj = self.pool.get('stock.move')
33
def get_parent_move(move_id):
36
productions = self.browse(cr, uid, ids)
37
for production in productions:
38
- res[production.id] = False
39
+ res[production.id] = {}
40
if production.move_prod_id:
41
parent_move_line = get_parent_move(production.move_prod_id.id)
43
move = move_obj.browse(cr, uid, parent_move_line)
44
- if field_name == 'name':
45
- res[production.id] = move.sale_line_id and move.sale_line_id.order_id.name or False
46
- if field_name == 'client_order_ref':
47
- res[production.id] = move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False
48
+ for field_name in field_names:
49
+ if field_name == 'sale_name':
50
+ res[production.id][field_name] = move.sale_line_id and move.sale_line_id.order_id.name or False
51
+ if field_name == 'sale_ref':
52
+ res[production.id][field_name] = move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False
53
+ if field_name == 'sale_id':
54
+ res[production.id][field_name] = move.sale_line_id and move.sale_line_id.order_id.id or False
55
+ if field_name == 'sale_line_id':
56
+ res[production.id][field_name] = move.sale_line_id and move.sale_line_id.id or False
57
+ if field_name == 'partner_id':
58
+ res[production.id][field_name] = move.sale_line_id and move.sale_line_id.order_id.partner_id.id or False
62
- 'sale_name': fields.function(_ref_calc, method=True, multi='sale_name', type='char', string='Sales Name', help='Indicate the name of sales order.'),
63
- 'sale_ref': fields.function(_ref_calc, method=True, multi='sale_name', type='char', string='Sales Reference', help='Indicate the Customer Reference from sales order.'),
64
+ 'sale_name': fields.function(_get_sale_ref, method=True, multi='sale_name', type='char', size=64, string='Sales Name', help='Indicate the name of sales order.', store=True),
65
+ 'sale_ref': fields.function(_get_sale_ref, method=True, multi='sale_name', type='char', size=64, string='Sales Reference', help='Indicate the Customer Reference from sales order.', store=True),
66
+ 'sale_id': fields.function(_get_sale_ref, method=True, multi='sale_name', type='many2one', relation='sale.order', string='Sale Order', help='', store=True),
67
+ 'sale_line_id': fields.function(_get_sale_ref, method=True, multi='sale_name', type='many2one', relation='sale.order.line', string='Sale Line', help='', store=True),
68
+ 'partner_id': fields.function(_get_sale_ref, method=True, multi='sale_name', type='many2one', relation='res.partner', string='Partner', help='', store=True),
73
=== modificado archivo sale_mrp/sale_mrp_view.xml
74
--- sale_mrp/sale_mrp_view.xml 2011-06-09 18:24:44 +0000
75
+++ sale_mrp/sale_mrp_view.xml 2011-06-09 18:26:02 +0000
77
<xpath expr="/form/notebook/page/field[@name='move_prod_id']" position="after">
78
<field name="sale_name" groups="base.group_extended"/>
79
<field name="sale_ref" groups="base.group_extended"/>
80
+ <field name="sale_id" groups="base.group_extended"/>
81
+ <field name="sale_line_id" groups="base.group_extended"/>
82
+ <field name="partner_id" groups="base.group_extended"/>