我需要将自定义模块中的一个字段关联到一个按钮,以便放置在 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, 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()
这里,Cantidad
应该是自动关联到采购订单的字段,我的意思是,在OpenErp中的“报价单”和“采购订单”中,当确认拣货时Product
仓库中的库存自动更新,“product_qty
”。
我需要做同样的事情,但不是对 OpenErp 中的库存或仓库,而是对我自定义模块中的这个 Cantidad
字段,因为有些元素可以从仓库和其他元素购买和管理来自这个模块。
我在Purchase Order
表单中看到了按钮,我可以为此任务创建一个新按钮,但我的问题是,如何将此字段与Purchase Order<关联起来
在我的自定义模块中,同时保持与库存的常规关系?
进一步理解,这不会是自动更新,只是独立更新,取决于何时点击此按钮。
我希望我已经解释清楚了。
提前致谢。
最佳答案
我不确定我是否清楚地理解您的问题,但让我尝试向您介绍一种通用方法。
首先,您需要了解OpenERP中库存位置和产品库存的概念。
OpenERP 中库存的基本构建 block 是产品交易/产品移动。如果您将产品 AAA 从位置 XXX 移动到位置 YYY,您将在 YYY 增加 AAA 的库存,而 AAA 的库存将在 XXX 减少。当您购买产品时,产品将从“供应商位置”移动到您的“库存位置”。当您销售某物时,您是在将产品从“库存位置”转移到“客户位置”。因此,特定位置的产品库存将是进出产品的汇总。
当您想更新 openERP 中的产品库存时,您要做的就是将库存从“库存位置”移动到其他虚拟位置(如客户位置、库存损失、生产位置等)
让我知道您从这个角度的想法,我会更新答案以专注于为您提供解决方案。
关于python - 关联自定义模块字段 - 产品 - OpenErp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16866481/