One2Many 字段 Odoo 的不规则性
irregularity with One2Many field Odoo
我有以下问题 我正在创建一个预算副本的表格,但这种类型的预算不包含增值税百分比并且货物不会通过会计。
好吧,下面的问题是我创建了一个名为 budget.table 的模型
如下:
class TableElements(models.Model):
_name = 'budget.table'
product_id = fields.Many2one('product.product', string='Product',ondelete='restrict', index=True)
name = fields.Text(string='Description', required=True)
quantity = fields.Float(string='Quantity',required=True, default=1)
price_unit = fields.Float(string='Unit Price', required=True,)
price_subtotal = fields.Float(string='Amount',store=True, readonly=True)
我有另一个名为 budget.two 的模型,如下所示:
class BudgetTwo(models.Model):
_name = 'budget.two'
name = fields.Char(string ='Nombre', copy=False, index=True ,default ="Nuevo")
partner_id =fields.Many2one('res.partner' ,string ='Cliente', copy=False, index=True,required=True)
deliver_date = fields.Date(string ='Fecha de Entrega')
expiration_date = fields.Date(string ='Fecha de expiración')
pay_place =fields.Many2one('account.payment.term' ,string='Plazo de Pago')
order_line = fields.One2many('budget.table','id' ,string = 'Pedidos' )
total = fields.Float(string = 'Total:' ,compute="_total")
我想要:正如您在 'budget.two' 中看到的,有一个 One2Many 字段,我将添加所有新产品,这些新产品又将保存在我创建的此类新预算中已经在没有增值税的情况下发表评论,会计模块不会发生这种情况。
当我select我要保存One2manny的产品时,我将其留空。示例:
所以应该保留:
但是当你保存它的时候,看看它是如何在 One2MAny 字段中没有任何元素的情况下存储的:
[![enter code here][2]][2]
在 'budget.table' 中添加此字段:
budget_two_id = fields.Many2one('budget.two')
在 'budget.two' 中更正此字段:
order_line = fields.One2many('budget.table', 'budget_two_id', string='Pedidos')
重点是任何 One2many 字段都应该在另一个模型上有一个反向字段 (Many2one) 作为外键。
我有以下问题 我正在创建一个预算副本的表格,但这种类型的预算不包含增值税百分比并且货物不会通过会计。
好吧,下面的问题是我创建了一个名为 budget.table 的模型 如下:
class TableElements(models.Model):
_name = 'budget.table'
product_id = fields.Many2one('product.product', string='Product',ondelete='restrict', index=True)
name = fields.Text(string='Description', required=True)
quantity = fields.Float(string='Quantity',required=True, default=1)
price_unit = fields.Float(string='Unit Price', required=True,)
price_subtotal = fields.Float(string='Amount',store=True, readonly=True)
我有另一个名为 budget.two 的模型,如下所示:
class BudgetTwo(models.Model):
_name = 'budget.two'
name = fields.Char(string ='Nombre', copy=False, index=True ,default ="Nuevo")
partner_id =fields.Many2one('res.partner' ,string ='Cliente', copy=False, index=True,required=True)
deliver_date = fields.Date(string ='Fecha de Entrega')
expiration_date = fields.Date(string ='Fecha de expiración')
pay_place =fields.Many2one('account.payment.term' ,string='Plazo de Pago')
order_line = fields.One2many('budget.table','id' ,string = 'Pedidos' )
total = fields.Float(string = 'Total:' ,compute="_total")
我想要:正如您在 'budget.two' 中看到的,有一个 One2Many 字段,我将添加所有新产品,这些新产品又将保存在我创建的此类新预算中已经在没有增值税的情况下发表评论,会计模块不会发生这种情况。
当我select我要保存One2manny的产品时,我将其留空。示例:
所以应该保留:
但是当你保存它的时候,看看它是如何在 One2MAny 字段中没有任何元素的情况下存储的:
[![enter code here][2]][2]
在 'budget.table' 中添加此字段:
budget_two_id = fields.Many2one('budget.two')
在 'budget.two' 中更正此字段:
order_line = fields.One2many('budget.table', 'budget_two_id', string='Pedidos')
重点是任何 One2many 字段都应该在另一个模型上有一个反向字段 (Many2one) 作为外键。