0
我试图从CSV数据导入Order_line
形式,我看到这个警告找到多个匹配字段“订单行”
Found multiple matches for field 'Order Line' (2 matches) between rows 2 and 6 (4 more)
Found multiple matches for field 'Order Line' (2 matches) between rows 2 and 6
Found multiple matches for field 'Order Line' (2 matches) between rows 2 and 6
Found multiple matches for field 'Order Line' (2 matches) between rows 2 and 6
Found multiple matches for field 'Order Line' (2 matches) between rows 2 and 6
而且由于这一切的ORDER_LINES的正在创建针对同一用户,但是如果你看到我的csv的第一列是account_number。我们有两个不同的栏目。
CSV
customer/account_number,customer/first_name,customer/last_name,customer/account_type,order/transaction_id,order/product_code,order/quantity
1160925,Charles L.,Richards,Segregated,10981036,G108P70NG,50
1160925,Charles L.,Richards,Segregated,10981037,G108P70NG,150
1160925,Charles L.,Richards,Segregated,10981038,G108P70NG,250
1160925,Charles L.,Richards,Segregated,10981039,G11270NG,350
1160243,"Tracy A., Jr.",Tolar,Segregated,23231554,G108P70NG,750
注意
秩序CSV标题居然是order_line
我们只是给它改名为CSV模板客户幕后。
ORDER_LINE创建方法
@api.model
def create(self, vals):
product_id = False
product_code = vals.get('product_code')
if product_code:
product = self.env['amgl.products'].search([
('product_code', '=', product_code)
])
if product:
product_id = product[0].id
vals.update({
'products': product_id,
})
record = super(OrderLine, self).create(vals)
if (float(record['total_received_quantity']) > float(record['quantity'])):
record.state = 'pending'
return record
订购专线模式
class OrderLine(models.Model):
_name = 'amgl.order_line'
_description = 'Order Lines'
name = fields.Char()
customer_id = fields.Many2one('amgl.customer', string='Customer Name',
default=lambda self: self._context.get('customer_id', False),required=True)
导入模型
class CustodianDataImport(models.Model):
_name = 'amgl.custodian_data_import'
_description = 'Custodian Data Import'
customer = fields.One2many('amgl.customer', 'custodian_import_id', string='Customer')
order = fields.One2many('amgl.order_line', 'custodian_import_id', string='Order Line')
钍上面的模型是我正在执行导入的单独模型,并且从此模型中创建了针对客户的所有订单。
您是否试图直接从订单行中导入客户数据?您是否正在使用我们在创建新的虚拟域或新的瞬态模型的其他问题中告诉您的方法? – ChesuCR
如果您重写创建方法来创建订单行,然后验证客户没有在数据库中复制 – ChesuCR
请将创建方法添加到问题以检查它是否正确 – ChesuCR