odoo 以下字段无效

odoo the following fields are invalid

为了把很多订单行合并到一行"quantity, total_price",尝试用一个按钮打印出来。我收到此错误 the following fields are invalid order_line_consolidation,我做了什么:

1- 创建了一个带有 One2many 字段的向导 order_line_consolidation

class sale_order_consolidation(models.TransientModel):

_name = "sale.order.consolidation"
_description = 'consolidation wizard'

order_line_consolidation = fields.One2many('sale.order.line', 'order_id')

2-合并行的功能,

3-打印函数

def print_quotation(self, cr, uid, ids, context=None):


    datas = {}
    if context is None:

        context = {} 
    data = self.read(cr, uid, ids)[0]
    datas = {   'ids': [],
                'model': 'sale.order',
                'form': data
                }

    return {'type': 'ir.actions.report.xml',
            'report_name': 'sale.report_saleorder',
            'datas': datas
            }

您的 sale_order_consolidation 中的字段似乎无法存储到您的数据库中,因此您只需添加 store=True。 我的建议:

1- 创建您自己的报告(自定义报告)以进行打印。然后执行以下操作;

class sale_order_consolidation(models.Model):

    _name = "sale.order.consolidation"
    _description = 'consolidation wizard'

    order_line_consolidation = fields.One2many('sale.order.consolidation.line', 'order_id')

打印方式:

def print_quotation2(self, cr, uid, ids, context=None):
    return self.pool['report'].get_action(cr, uid, ids, 'your_module_name.report_report_name', context=context)

第二个模型:

class SaleOrderLineconsolidation(models.Model):
     _name = "sale.order.consolidation.line"

     order_id = fields.Many2one('sale.order.consolidation','order id',store=True)
     sale_id  = fields.Many2one('sale.order.line','sale_id',store=True)

     field = fields.Char(string='field',store=True)
     .      .       .
     .      .       .
     ...other fields......