- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在使用 odoo 10,我有两个模型 Order_Line 和 Products。
订单热线
class OrderLine(models.Model):
_name = 'order_line'
_description = 'Order Lines'
name = fields.Char()
products = fields.Many2one('amgl.products', String='Products')
class Products(models.Model):
_name = 'products'
_description = 'Products'
_sql_constraints = [
('uniq_poduct_code', 'unique(product_code)', 'Product Code already exists!')
]
name = fields.Char()
product_code = Char()
Id
.如何处理这个,我们使用产品代码,系统自动填充与该产品代码关联的产品。
Product Code
in products 表也是唯一的,所以没有重复的机会。
customer/account_number,customer/first_name,customer/last_name,customer/account_type,order/transaction_id,order/products/product_code,order/quantity,order/customer_id/id
最佳答案
案例1 : 数据库中没有存储有客户提供给您的任何产品代码的产品
如果尚未在数据库中创建产品代码,您应该有两个 CSV 文件(Products.csv 和 OrderLine.csv)。第一个必须有三列( id
、 name
和 product_code
)。第二个也必须有三列( id
、 name
和 products/id
)。所以你只需要在 id
下创建一个 XML ID。 Products.csv 中的列,并从列的相应行中调用此 XML ID products/id
文件 OrderLine.csv。
案例2 : 客户给你的产品代码属于数据库中已有的产品
现在,客户为您提供了数据库中已经存在的产品的产品代码。在这种情况下,您不必创建 Products.csv 文件。您需要知道哪些产品的 XML ID 具有客户提供给您的产品代码。为此,您可以通过 Odoo 的界面进入模型的树状 View products
(如果此 View 不存在,则必须创建它)。然后,您必须选择所有记录(如果需要,请单击右上角的数字 80 以每页显示更多记录)。全部选中后,单击 More
按钮和战后 Export
.选择列 product_code
和 name
然后继续。例如,将生成的 CSV 文件另存为 Products.csv。打开它,您将看到导出产品的所有XML ID(如果它们没有XML ID,则在导出后他们会做-如果没有任何人,导出会为每个导出的记录生成XML ID-) .现在,我猜客户已经给了您类似的文件,其中包含订单行名称、产品代码列,因此将产品代码列值替换为您刚刚导出的产品的相应 XML ID。所以最后你应该有一个文件要导入,OrderLine.csv,id
, name
和 products/id
列。
案例3 : 数据库中存储了一些属于现有产品的产品代码,还有一些仍然不存在
在这种情况下,您必须将案例 1 和案例 2 结合起来,首先,按照案例 2 中的描述导出产品,然后使用代码尚不存在的产品创建一个新产品,如案例 1 中所述。然后将客户提供给您的产品代码替换为案例 2 中所述的相应代码。
备注 :如果您有数千条记录要导入并手动替换它们,则此过程将为您提供大量时间。在这种情况下,必须在 CSV 编辑器中创建一个宏来进行替换(通过搜索和替换)。例如,使用 LibreOffice,您可以使用 Python 执行宏。
Example (Case 3)
The customer has given you a file of order lines, with two lines:
- Name: OL A, Product Code: AAA
- Name: OL B, Product Code: BBB
You export products from Odoo interface and you get a file with one line:
id,name,product_code
__export__.products_a,"Product A","AAA"You look for the coincidences of the product codes in both files, and do the replacements in a copy of the customer file, so now you have this:
- Name: OL A, Product Code:
__export__.products_a
- Name: OL B, Product Code: BBB
Then you create a new CSV Products.csv and put in there the products whose product code don't exist yet:
id,name,product_code
__import__.products_b,"Product B","BBB"Now apply the replacements again comparing this new file with the one we had, and you will get this:
- Name: OL A, Product Code:
__export__.products_a
- Name: OL B, Product Code:
__import__.products_b
Convert this file to a right CSV format for Odoo, and save it as OrderLine.csv:
id,name,products/id
__import__.order_line_1,"OL A",__export__.products_a
__import__.order_line_2,"OL B",__import__.products_bAnd finally, import the files, and take into account: import Products.csv before OrderLine.csv.
Char
字段命名
product_code
在
order_line
模型(它会暂时存在)。
@api.model
def create(self, vals):
product_id = False
product_code = vals.get('product_code', False)
if product_code:
product = self.env['products'].search([
('product_code', '=', product_code)
])
if product:
product_id = product[0].id
vals.update({
'products': product_id,
})
return super(OrderLine, self).create(vals)
order/products/product_code
如
product_code
.导入 CSV 文件。每次导入记录都会调用
order_line
的ORM create方法模型。
product_code
模型中删除
order_line
列,以删除垃圾)。
关于mysql - Odoo - 使用代码而不是 id 搜索产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47753249/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 6年前关闭。 Improve this qu
我想,如果我单击按钮,删除数据并返回 TreeView 。我可以使用 unlink 方法删除数据。但我不能重定向到 TreeView 。我该怎么做? 这是我的代码: def action_de
我最近安装了 Odoo 9.0。但是,我需要一个仅适用于 Odoo 8.0 的模块。 我想知道是否可以对此模块进行微小的更改以使其兼容 Odoo 9.0?新模块只是一个日历,仅使用 Web 界面:Li
嗨,我很难确定人类的权限Odoo10 的资源模块涉及休假管理工作流程。 我在休假类型中激活了双重验证。假设我有一个部门,拥有以下员工: Manager01 (Manager of the Depart
我正在尝试将 odoo 安装从 8.0 升级到 9.0。到目前为止,我所做的如下: 从生产系统备份 odoo 数据库 在我当前的系统中安装了备份数据库作为测试 复制了我系统文件夹中的 odoo 文件夹
如何在 odoo 8.0 (OpenERP) 上删除“Powered by Odoo”? 最佳答案 首先转到您的 Odoo Web 模块并打开以下文件。 addons => web => views
我开发了一个同时支持 odoo 10 和 odoo 11 的应用程序,我想在一个部署下部署这个应用程序。意思是如果我访问我的 odoo 应用程序,我应该看到一个应用程序而不是两个应用程序,当我从下拉列
我已经按照教程安装了 odoo+postgres当我尝试在我的 linux 终端中运行 ./odoo-bin 命令时,我得到了这个错误: 2019-09-15 08:48:30,765 5126 ER
我按照教程在 Odoo 8 中创建了一个模块。我在用户中激活了技术功能,然后更新了模块列表,但它没有出现在列表中。 我该怎么办? 最佳答案 跟踪以下内容: checkout __init__.py,
我需要将“Powered by Odoo”页脚中的“Powered”更改为“Made”, 所以我的 Odoo(以前的 OpenERP)版本 8.0-aab3d9f 的页脚将是“Made by Odoo
默认情况下,当我在 odoo 中创建新数据库时,表是在公共(public)模式中创建的。有没有办法更改此配置以及 odoo 创建和使用另一个定义的方案? 最佳答案 没有办法做到这一点,odoo 默认使
我正在尝试使用与 Django 相同的功能: 在 Odoo 中,我有: 如果“c.id = cat_id”,我需要附加“active”类 它是如何在 Odoo 中完成的? 我正在使用:
我已经发送了一些电子邮件营销事件,在“群发邮件”中,我有“电子邮件”按钮的详细信息。当我点击它时,我有“邮件 ID(技术)”、“消息 ID”、“已发送”等列。但是我看不到我发送的电子邮件。 我怎么能看
在 Odoo 中创建发票时,我想过滤“客户”的可用合作伙伴选择。具体来说,我想将合作伙伴联系记录限制为“发票地址”类型的记录,即 res_partner 上的域。的 [('type','=','inv
我是 ODOO 新手,正在寻找捕获 的方法考勤模块中的地理位置 ODOO 的。需要同时记录入住和退房地点 最佳答案 检查此模块,它捕获地理位置:https://odoo-community.org/s
Odoo 中的 Product Master 需要两个不同的表是什么? product.product 和 product.template 有何不同? 最佳答案 由于产品变体,Odoo 有两种产品模
在V11企业版中,部分机型有存档功能,但公司没有。如果我有多家公司,但有一家公司已经停业,我如何禁用或存档该公司,使其不会出现在所有模块中,甚至管理员也无法将其分配给任何用户?似乎一旦创建了公司,即使
是否有一种简单的方法将 OpenERP (oodo) 中的新自定义字段(在客户记录或订单项目中)与外部链接(即描述或 iframe)关联起来,以便它可以链接到不同的系统? 创建记录时,是否有一种简单的
我在odoo社区版中更改了我的公司数据,但它从未反射(reflect)出来,即使我在浏览器缓存中进行了更改。请帮忙enter image description here ODoo 最佳答案 你有两个
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 6 年前。 Improve th
我是一名优秀的程序员,十分优秀!