~openerp-community/openobject-addons/trunk-addons-community

« back to all changes in this revision

Viewing changes to product_loan/stock.py

  • Committer: Alexis de Lattre
  • Date: 2014-01-20 16:28:33 UTC
  • Revision ID: alexis@via.ecp.fr-20140120162833-wozad66s7ln25ec2
Enhance the code ; the generation of the return picking is now inheritable. The return stock move is now linked to the out stock move (move_dest_id)
Small update to coding style.
Loan IN and OUT are now regular M2O fields and not properties (warning : it requires data migration).

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
##############################################################################
23
23
 
24
24
 
25
 
from osv import fields,osv
 
25
from openerp.osv import fields, osv
26
26
 
27
27
 
28
28
class stock_picking(osv.osv):
45
45
class stock_warehouse(osv.osv):
46
46
    _inherit = "stock.warehouse"
47
47
    _columns = {
48
 
        'property_stock_loan_inside_location': fields.property(
49
 
            'stock.location',
50
 
            type='many2one',
51
 
            relation='stock.location',
52
 
            string="Loan Inside Location",
53
 
            method=True,
54
 
            view_load=True,
55
 
            domain="[('usage', '=', 'internal')]",
56
 
            help="Loan Inside Location",
57
 
            required=True),
58
 
        'property_stock_loan_outside_location': fields.property(
59
 
            'stock.location',
60
 
            type='many2one',
61
 
            relation='stock.location',
62
 
            string="Loan Outside Location",
63
 
            method=True,
64
 
            view_load=True,
65
 
            domain="[('usage', '!=', 'internal')]",
66
 
            help="Loan OutSide Location",
67
 
            required=True),
 
48
        'loan_in_location_id': fields.many2one(
 
49
            'stock.location', "Loan Inside Location",
 
50
            domain="[('usage', '<>', 'view')]", required=True),
 
51
        'loan_out_location_id': fields.many2one(
 
52
            'stock.location', "Loan Outside Location",
 
53
            domain="[('usage', '<>', 'internal')]", required=True),
68
54
    }
 
55
 
69
56
stock_warehouse()
70
57
 
71
58
 
157
144
        return res
158
145
 
159
146
    _columns = {
160
 
        'loan_manager_id'        : fields.many2one('res.users', 'Loan Manager', select="1"),
161
 
        'current_partner_loan_id': fields.function(_current_partner_loan_id, method=True, type="many2one", relation="res.partner",
162
 
                string="Current Partner Loan"),
163
 
        'current_loan_end_date'  : fields.function(_current_loan_end_date, method=True, type="date", string="Current Loan End Date"),
164
 
        'current_loan_id'        : fields.function(_current_loan_id, method=True, type="many2one", relation="sale.order",
165
 
                string="Current Loan"),
 
147
        'loan_manager_id': fields.many2one(
 
148
            'res.users', 'Loan Manager', select="1"),
 
149
        'current_partner_loan_id': fields.function(
 
150
            _current_partner_loan_id, type="many2one", relation="res.partner",
 
151
            string="Current Partner Loan"),
 
152
        'current_loan_end_date': fields.function(
 
153
            _current_loan_end_date, type="date", string="Current Loan End Date"),
 
154
        'current_loan_id': fields.function(
 
155
            _current_loan_id, type="many2one", relation="sale.order",
 
156
            string="Current Loan"),
166
157
    }
167
158
 
168
159
stock_production_lot()
172
163
    _inherit = "stock.report.prodlots"
173
164
 
174
165
    _columns = {
175
 
        'partner_id'    : fields.related('prodlot_id', 'current_partner_loan_id', type="many2one", relation='res.partner', readonly=True),
176
 
        'partner_name'  : fields.related('partner_id', 'name', type="char", string="Partner", readonly=True),
177
 
        'manager_id'    : fields.related('prodlot_id', 'loan_manager_id', type="many2one", relation='res.users', readonly=True),
178
 
        'manager_name'  : fields.related('manager_id', 'name', type="char", string="Loan Manager", readonly=True),
 
166
        'partner_id': fields.related('prodlot_id', 'current_partner_loan_id', type="many2one", relation='res.partner', readonly=True),
 
167
        'partner_name': fields.related('partner_id', 'name', type="char", string="Partner", readonly=True),
 
168
        'manager_id': fields.related('prodlot_id', 'loan_manager_id', type="many2one", relation='res.users', readonly=True),
 
169
        'manager_name': fields.related('manager_id', 'name', type="char", string="Loan Manager", readonly=True),
179
170
    }
180
171
 
181
172
stock_report_prodlots()