~pexego/openobject-addons/6.1-pexego-sale_commission

« back to all changes in this revision

Viewing changes to mrp_bom_formula/mrp_bom.py

  • Committer: Omar (pexego)
  • Date: 2012-07-27 08:40:22 UTC
  • Revision ID: omar@pexego.es-20120727084022-qp3ludpr3vsuyuf6
[ADD] Traceability modules ported to 6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    Copyright (C) 2004-2011 Pexego Sistemas Informáticos. All Rights Reserved
 
5
#    $Omar Castiñeira Saavedra$
 
6
#
 
7
#    This program is free software: you can redistribute it and/or modify
 
8
#    it under the terms of the GNU General Public License as published by
 
9
#    the Free Software Foundation, either version 3 of the License, or
 
10
#    (at your option) any later version.
 
11
#
 
12
#    This program is distributed in the hope that it will be useful,
 
13
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
#    GNU General Public License for more details.
 
16
#
 
17
#    You should have received a copy of the GNU General Public License
 
18
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
#
 
20
##############################################################################
 
21
 
 
22
from osv import osv, fields
 
23
 
 
24
class mrp_bom(osv.osv):
 
25
 
 
26
    _inherit = "mrp.bom"
 
27
    _order = "bom_id,sequence"
 
28
 
 
29
    _columns = {
 
30
        'formula': fields.char('Formula', size=255),
 
31
        'eval_type': fields.selection([('fixed', 'Fixed'),('computed','Computed')], 'Computation', help="Evaluation type, fixed quantity or quantity over formula field"),
 
32
        'seq_lines_id': fields.many2one('ir.sequence', 'Sequence', readonly=True)
 
33
    }
 
34
 
 
35
    _defaults = {
 
36
        'eval_type': 'fixed'
 
37
    }
 
38
 
 
39
    def create(self, cr, uid, vals, context=None):
 
40
        if context is None: context = {}
 
41
 
 
42
        seq_id = self.pool.get('ir.sequence').search(cr, uid, [('code', '=', 'mrp.bom.seq')], order="id")
 
43
        if seq_id:
 
44
            vals['seq_lines_id'] = self.pool.get('ir.sequence').copy(cr, uid, seq_id[0], {'number_next': 1})
 
45
 
 
46
        if vals.get('bom_id', False):
 
47
            bom = self.browse(cr, uid, vals['bom_id'])
 
48
            if bom.seq_lines_id:
 
49
                num = self.pool.get('ir.sequence').get_id(cr, uid, bom.seq_lines_id.id)
 
50
                vals['sequence'] = num
 
51
 
 
52
        return super(mrp_bom, self).create(cr, uid, vals, context=context)
 
53
 
 
54
mrp_bom()
 
 
b'\\ No newline at end of file'