I need to associate a field with a custom module with a button that will be placed on the Purchase Order OpenErp form.
When the product selection is confirmed, this button will “discharge” the quantity of this product, filled in the “quantity” field of my custom module.
For instance:
class certificados_line(osv.osv): _name = 'certificados.line' _description = "Items del Certificado" def multi_a_b(self, cr, uid, ids, name, arg, context=None): res = {} for record in self.browse(cr, uid, ids,context): res[record.id] = record.Cantidad * record.Precio_Unitario_Declarado return res _columns = { 'codigo_n' : fields.related( 'product_id', 'codigo_n', type='char', size=64, string='Codigo Arancelario', store=True, readonly=True, ), 'product_id' : fields.many2one( 'product.product', 'Material', ), 'Descripcion_Arancelaria' : fields.many2one( 'product.category', 'Descripcion Arancelaria', change_default=True, domain="[('type','=','normal')]", ), 'tec_esp': fields.related( 'product_id', 'tec_esp', type='char', size=64, string='Especificaciones tecnicas', store=True, readonly=True, ), 'Cantidad' : fields.float( 'Cantidad', ), 'Unidad_de_Medida': fields.many2one( 'product.uom', 'Unidad de Medida', ), 'Precio_Unitario_Declarado' : fields.float( 'Precio Unitario Declarado', ), 'Moneda' : fields.many2one( 'res.currency', 'Moneda', ), 'Valor_En_Divisas' : fields.function( multi_a_b, type='integer', string='Valor En Divisas', ), 'requisicion_id' : fields.many2one( 'certificados.certificados', 'Certificados de No Produccion', ondelete='cascade', ), 'Cantidad_Consumida' : fields.related( 'product_id', 'outgoing_qty', type='float', string='Cantidad Consumida', store=True, readonly=True, ), 'Cantidad_Disponible' : fields.related( 'product_id', 'qty_available', type='float', string='Cantidad Disponible', store=True, readonly=True, ), } certificados_line()
Here Cantidad should be a field that will be automatically associated with the purchase order, I mean, in the "Quote Request" and "Purchase Request" in OpenErp, when the collection is confirmed by the shares of Product warehouse is automatically updated, " product_qty ".
I need to do the same, but not with stock or warehouse in OpenErp, but only in this Cantidad field in my custom module, because some items can be bought and managed from the warehouse, and others from this module.
I saw buttons on the Purchase Order form, I could create a new one for this task, but my problem is how to link this field to the Purchase Order in my custom module, while maintaining the usual stock relationship?
For further understanding, this will not be an automatic update, just an independent update, depending on whether this button is pressed or not.
I hope I explained it myself.
Thanks in advance.