【发布时间】:2020-04-04 04:03:27
【问题描述】:
我正在使用https://github.com/tfrancoi/odoo_csv_import 将数据导入 Odoo “res.partner”模型。导入大部分字段没有问题,但是当我尝试导入字段 state_id 时会抛出此错误:“Found multiple matches for field 'State' (2 matches)”。
res_partner_mapping = {
(........ more fields here)
'country_id/id' : mapper.const('base.es'),
'state_id': mapper.map_val('myStateField', my_state_dictionary),
}
这里 my_state_dictionary 只返回搜索到的 state_id,例如“AV”、“M”或“B”。
问题是 state_id 是一个组合键,所以它应该被 country_id 和 state_id 过滤。例如,“AV”是西班牙的一个州,但它在意大利也是一个不同的州,所以如果只通过 state_id 过滤它会返回 2 条记录。
字段在 Odoo 中是这样声明的:
state = fields.Many2one('country',related=city.country)
如何指定关系 related=city.country 以使用 odoo_csv_import 导入数据?
【问题讨论】: