Esempio n. 1
0
    def _check_data_before_save(self, cr, uid, data):
        # import pdb
        # pdb.set_trace()
        # _logger.info(">> check_before >> 1 >> data = %s", data)

        if 'categ_id' in data:
            cid = data['categ_id']
            # if not comm.is_raw_material_by_category_id(self, cr, uid, [cid])[cid]:
            if comm.is_raw_material(self, cr, uid, cid):
                data['type'] = 'product'
                data['uom_id'] = comm.get_uom_m2_id(self, cr, uid)
                data['uom_po_id'] = comm.get_uom_m2_id(self, cr, uid)
                data['bacha_material'] = False
                data['bacha_marca'] = False

            elif comm.is_bachas(self, cr, uid, cid):
                data['type'] = 'product'
                data['uom_id'] = comm.get_uom_units_id(self, cr, uid)
                data['uom_po_id'] = comm.get_uom_units_id(self, cr, uid)
                data['material'] = False
                data['color'] = False
                data['finished'] = False

            else:
                if comm.is_inputs(self, cr, uid, cid):
                    data['type'] = 'consu'
                elif comm.is_services(self, cr, uid, cid):
                    data['type'] = 'service'
Esempio n. 2
0
    def onchange_category_id(self, cr, uid, ids, categ_id):
        """
        Se cambio Categ. Prod, >> determino y seteo la view segun Categ. Prod.
        """
        v = {}
        if not categ_id:
            return v

        v['is_raw'] = False
        v['is_bacha'] = False
        v['uom_readonly'] = False

        if comm.is_raw_material(self, cr, uid, categ_id):
            v['type'] = 'product'
            v['is_raw'] = True
            v['uom_readonly'] = True
            v['uom_id'] = comm.get_uom_m2_id(self, cr, uid)
            v['uom_po_id'] = comm.get_uom_m2_id(self, cr, uid)

        elif comm.is_bachas(self, cr, uid, categ_id):
            v['type'] = 'product'
            v['is_bacha'] = True
            v['uom_readonly'] = True
            v['uom_id'] = comm.get_uom_units_id(self, cr, uid)
            v['uom_po_id'] = comm.get_uom_units_id(self, cr, uid)

        elif comm.is_inputs(self, cr, uid, categ_id):
            v['type'] = 'consu'

        elif comm.is_services(self, cr, uid, categ_id):
            v['type'] = 'service'

        # _logger.info("10 >> onchange_category_id >> v = %s", v)
        return {'value': v}
Esempio n. 3
0
    def _get_uom_readonly(self, cr, uid, ids, field_name, arg, context=None):
        res = {}
        if not ids:
            return res

        for p in self.browse(cr, uid, ids, context=context):
            ro = comm.is_raw_material(self, cr, uid, p.categ_id.id) or \
                 comm.is_bachas(self, cr, uid, p.categ_id.id)
            res[p.id] = ro

        # _logger.info("11 >> _get_readonly >> res = %s", res)
        return res
Esempio n. 4
0
    def _get_categ_name(self, cr, uid, ids, field_name, arg, context=None):
        # _logger.info("09 >> _get_categ_str >> ids = %s", ids)
        res = {}
        if not ids:
            return res

        for p in self.browse(cr, uid, ids, context=context):
            if comm.is_raw_material(self, cr, uid, p.categ_id):
                res[p.id] = 'raw'
            elif comm.is_bachas(self, cr, uid, p.categ_id):
                res[p.id] = 'bac'
            elif comm.is_inputs(self, cr, uid, p.categ_id):
                res[p.id] = 'inp'
            elif comm.is_services(self, cr, uid, p.categ_id):
                res[p.id] = 'ser'
            else:
                res[p.id] = '*'

        # _logger.info("10 >> _get_categ_str >> res = %s", res)
        return res
Esempio n. 5
0
    def _get_attrs(self, cr, uid, ids, context=None):
        res = {}
        if not ids:
            return res

        for p in self.browse(cr, uid, ids, context=context):

            attrs = ""
            if comm.is_raw_material(self, cr, uid, p.categ_id.id):
                mat = dict(self._material).get(p.material)
                col = dict(self._color).get(p.color)
                fin = dict(self._finished).get(p.finished)
                attrs = "%s - %s - %s" % (mat, col, fin)

            elif comm.is_bachas(self, cr, uid, p.categ_id.id):
                mat = dict(self._bacha_material).get(p.bacha_material)
                mar = dict(self._bacha_marca).get(p.bacha_marca)
                attrs = "%s - %s" % (mar, mat)

            res.update({p.id: attrs})

        # _logger.info(">> _get_attrs >> 1 >> res = %s", res)
        return res