为了在一行中合并许多订单行" 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-巩固线条的功能, list of dictionary consolidation
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
}
答案 0 :(得分:1)
您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......