~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to sale_mrp_patch/sale_mrp.patch

  • Committer: Gabriela (Vauxoo)
  • Date: 2012-01-02 16:24:49 UTC
  • Revision ID: gabrielaquilarque97@gmail.com-20120102162449-lhxnrtif2ud36du2

[ADD] Added new module invoice_so.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
4
 
@@ -25,28 +25,12 @@
5
 
 class mrp_production(osv.osv):
6
 
     _inherit = 'mrp.production'
7
 
 
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.
14
 
         """
15
 
-        res = {}
16
 
-        if not field_names:
17
 
-            field_names = []
18
 
-        for id in ids:
19
 
-            res[id] = {}.fromkeys(field_names, False)
20
 
-        for f in field_names:
21
 
-            field_name = False
22
 
-            if f == 'sale_name':
23
 
-                field_name = 'name'
24
 
-            if f == 'sale_ref':
25
 
-                field_name = 'client_order_ref'
26
 
-            for key, value in self._get_sale_ref(cr, uid, ids, field_name).items():
27
 
-                res[key][f] = value
28
 
-        return res
29
 
-
30
 
-    def _get_sale_ref(self, cr, uid, ids, field_name=False):
31
 
         move_obj = self.pool.get('stock.move')
32
 
 
33
 
         def get_parent_move(move_id):
34
 
@@ -58,20 +42,30 @@
35
 
         res = {}
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)
42
 
                 if parent_move_line:
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
59
 
         return res
60
 
 
61
 
     _columns = {
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),
69
 
     }
70
 
 
71
 
 mrp_production()
72
 
 
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
76
 
@@ -11,6 +11,9 @@
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"/>
83
 
                 </xpath>
84
 
             </field>
85
 
         </record>
86
 
 
87