python – 关联自定义模块字段 – 产品 – OpenErp
我需要将自定义模块中的字段与放置在OpenErp的Purchase Order表单中的按钮相关联.
确认产品拣配后,此按钮将“排出”在我的自定义模块的“数量”字段中填写的此产品的数量. 例如: 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,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',string='Especificaciones tecnicas','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','Cantidad_Disponible' : fields.related( 'product_id','qty_available',string='Cantidad Disponible',} certificados_line() 在这里,Cantidad应该是与采购订单自动相关的字段,我的意思是,在OpenErp的“报价请求”和“采购订单”中,当确认拣配时,仓库中的产品库存会自动更新,“ product_qty”. 我需要做同样的事情,但不是在OpenErp中的库存或仓库,而是在我的自定义模块中的Cantidad字段,因为有些项目可以从仓库和其他模块中购买和管理. 我已经看到了采购订单表单中的按钮,我可以为此任务创建一个新按钮,但我的问题是,如何将此字段与我的自定义模块中的采购订单相关联,同时保持与库存的传统关系? 为了进一步理解,它不是自动更新,只是一个独立的更新,具体取决于单击此按钮的时间. 我希望我已经解释过了. 提前致谢. 解决方法
我不确定我是否清楚地理解你的问题,但让我试着给你一个通用的方法.
首先,您需要了解OpenERP中库存位置和产品库存的概念. OpenERP中库存的基本构建块是产品交易/产品移动.如果您将产品AAA从位置XXX移动到YYY位置,您将在YYY处压缩AAA的库存,并且AAA的库存将减少到XXX.购买产品时,产品将从“供应商位置”移至“库存地点”.当您在销售产品时,您正在将产品从“库存位置”移动到“客户位置”.因此,特定地点的产品库存将是移入和移出的产品的摘要. 当您想要在openERP中更新产品库存时,您需要做的是使库存从“库存位置”移动到其他虚拟位置(如客户位置,库存损失,生产地点等) 从这个角度让我知道你的想法,我会更新答案,专注于为你解决方案. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |