User Module Relative Field - Products - OpenErp

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.

+4
source share
1 answer

I'm not sure I understand your question clearly, but let me try to introduce you to a general approach.

First of all, you need to understand the concept of stock location and product stock in OpenERP.

The main building block for stocks in OpenERP are product / product transactions. If you move an AAA product from location XXX to location YYY, you increase stock for AAA in YYY, and stock AAA will be reduced by XXX. When you purchase a product, the product will be moved from "Vendor location" to your "stock location". When you sell something, you move products from your “warehouse” to “Customer’s location”. Thus, stocking a product at a specific location will be a summary of products moved and moved.

When you want to update the stock of a product in openERP, you need to make the stock move from the "stock location" to other virtual locations (for example, customer location, inventory loss, production site, etc.)

Let me know your thoughts from this perspective, and I will update the answer to focus on the solution for you.

+1
source

Source: https://habr.com/ru/post/1483871/


All Articles