I need to relate a field from a custom module to a button to be placed in the Purchase Order
form of OpenErp.
When a product picking is confirmed this button will "discharge" the quantity of this product filled in the "quantity" field of my custom module.
For example:
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 the field to be automatically related to the purchase order, I mean, in the "Request for Quotation" and "Purchase Order" in OpenErp, when the picking is confirmed the Product
stock in the warehouse gets automatically updated, "product_qty
".
I need to do the same but not with the stock or warehouse in OpenErp but just to this Cantidad
field in my custom module, because some items could be bought and are managed from the warehouse and others from this module.
I've seen the buttons in the Purchase Order
form, I could create a new one for this task, but my problem is, how to relate this field to the Purchase Order
in my custom module, while keeping the conventional relationship with stock?
For further understanding, it will not be an automatic update, just an independent update, depending on when this button is clicked or not.
I hope I've explained myself.
Thanks in advance.