我继承了res.partner类,并且有这两种方法:
jour_id = fields.Many2one('account.journal', string='Journal', required=False,
help="Default journal for damaged invoices")
acc_id = fields.Many2one('account.account', string='Account',
help="Default account used for invoices and lines from damaged invoices")
printer_fiscal = fields.Boolean(string='Manages fiscal printer',
help='Indicates that the company can operate a fiscal printer')
@api.model
def create(self, vals):
""" To create a new record,
adds a Boolean field to true
indicates that the partner is a company
"""
#if context is None:
#context = {}
ctx = self._context.copy()
ctx.update({'create_company': True})
return super(ResCompany, self).create(vals) …Run Code Online (Sandbox Code Playgroud) 在 odoo 中,您可以通过字段的 str 名称获取字段的值: exm:
name = getattr(self, 'name')
Run Code Online (Sandbox Code Playgroud)
我现在想要知道字段名称的类型是:
fields.Char, fields.Many2one, fields.Many2many .....
Run Code Online (Sandbox Code Playgroud)
所以我需要的是这样的
gettype(self, 'user_id')
Run Code Online (Sandbox Code Playgroud)
现在有办法知道odoo中的字段类型是什么吗?
我正在使用 odoo 10-e。我创建了自定义模块,在该模块中我想显示这样的 one2many 记录
----------------
| Long Cell |
----------------
| 1 | 2 |
----------------
Run Code Online (Sandbox Code Playgroud)
现在默认情况下,每列都有自己的标题,实际上是string=值。我想覆盖默认行为。
我有这个方法:
@api.multi
def create_printy(self):
copy_record = self.env['stock.picking'] # now you call the method directly
for record in self:
order_lines = []
for rec in record.order_lines:
order_lines.append(
(0,0,
{
'product_id': rec.isbn.id,
'product_qty': rec.qty,
}
))
copy_record.create({
'origin': order.name,
'picking_type_id.id': 'outgoing',
'move_lines': order_lines,
'move_type': 'direct',
'priority': '1',
'company_id': record.company_id.id,
})
Run Code Online (Sandbox Code Playgroud)
这是一个按钮,应该stock.picking从我的模型中创建一个新的。
我已经尝试过,picking_type_id.id但它似乎不起作用,在标准插件中的每个示例上,你只是看到picking_type_id,我的模型中也没有任何定义,但我虽然我可以传递一种可用的类型,它是outgoing(我需要的)。
现在,它向我抛出了这个:
Integrity Error
The operation cannot be completed, probably due to the following:
- deletion: you may be trying to delete a …Run Code Online (Sandbox Code Playgroud) 我正在开发 odoo 10。我想做的只是显示 404 页面,就像我们在其他网站中显示的那样,如果请求的页面不存在。
我正在向客户发送电子邮件,在该电子邮件模板中有一个要记录的链接,但有时具有较高用户角色的用户会由于某种原因删除该特定记录。我想在这种情况下显示 404 页面。
我开始使用 Odoo v8.0 的新 API,但在计算字段中找不到有关存储触发器的有用信息(对于 v7.0 和 v6.1):Store Parameter in Odoo v6
在 Odoo v8.0 中,我尝试使用与 v7.0 相同的语法,但无法使其工作,因为 JSON 响应无法返回到 Web 客户端:
<function _store_trigger> is not JSON serializable.
然后我读到存储参数已转换为仅布尔字段(没有触发器的字典):Odoo 存储函数:JSON 不可序列化
那么如何设置触发器来将计算(和相关)字段的值存储在数据库中?我想主要为他们制作过滤器和组,所以search function没有用。
我正在生成的所有默认报告和新报告都将打印在页面左侧.仅当报告以PDF格式生成时才会发生这种情况.在HTML格式中,报告显示正常.我做了一些研究,发现将wkhtmltox降级到版本0.21.1可以解决这个问题.我做到了,但问题仍然存在.
我正在尝试通过Python发送邮件(加载模板).
我在版本7中使用模型的功能执行send_mail了此操作email.template.现在,我希望它适用于版本8,但我无法管理它.
这不是关于SMTP服务器和模板的问题,因为如果我手动发送邮件,它就会正确地掌握它的命运.
它似乎没有进入函数send_mail(我在函数的第一行上面写了一个记录器信息消息,它永远不会出现).
这是我的代码:
return self.env['email.template'].send_mail(
self.env.cr, self.env.uid, template.id, self.id, force_send=True,
context=self.env.context)
Run Code Online (Sandbox Code Playgroud)
我还检查了函数需要template.id的self.id参数和参数是否正确.但是没有错误,没有消息,它忽略了这个功能.我也试过没有cr,uid和context,但相同的结果.
顺便说一句,send_mail函数有一个我以前从未见过的装饰器@api.cr_uid_id_context,其含义我不知道.
有人可以帮帮我吗?
如何使用其外部 ID 在数据库中查找记录?
假设我的数据文件中有以下记录:
<record model="product.product" id="product_to_find"> ... </record>
Run Code Online (Sandbox Code Playgroud)
如何在代码隐藏中检索它?
当我尝试打印任何发票的报告时,会弹出此错误,因此我从此链接下载了 wkhtmltopdf,http://wkhtmltopdf.org/downloads.html
之后,在设置->系统参数中,我创建了一个名为 wkhtmltopdf 的密钥,其值为C:\Program Files (x86)\wkhtmltopdf 但我仍然无法以 pdf 格式打印报告,因为此错误不会发生。(我在 Windows 上,这是图像)

这是我的 XML 代码,many2many_kanban 视图没有显示要删除的 X 按钮。
<record model="ir.ui.view" id="crm_customer_form_view_leads_inherited">
<field name="name">res.partner.form.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//form/sheet/notebook/page[@name='internal_notes']" position="after">
<page name="Employees" string="Empolyees">
<field name="employee_ids" widget="many2many_kanban"/>
</page>
</xpath>
</field>
</record>
Run Code Online (Sandbox Code Playgroud) 我必须在Odoo 8中将Purchase Order Line设置为可编辑.目前,Purchase.Order Model中的字段order_line具有以下修饰符:
'order_line': fields.one2many('purchase.order.line', 'order_id', 'Order Lines',
states={'approved':[('readonly',True)],
'done':[('readonly',True)]},
copy=True)
Run Code Online (Sandbox Code Playgroud)
因此,如果批准或完成,州是只读的.我想删除它.我试过以下:
<field name="order_line" position="attributes">
<attribute name="readonly">0</attribute>
</field>
Run Code Online (Sandbox Code Playgroud)
也,
<xpath expr="//field[@name='order_line']" position="attributes">
<attribute name="readonly">0</attribute>
</xpath>
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
请帮忙
谢谢,
class PurchaseOrder(models.Model):
'''
classdocs
'''
_name = 'purchase.order'
_inherit = 'purchase.order'
total_cases = fields.Integer('Total Cases', default=None)
appointment_number = fields.Char('Appointment Number', default=None)
order_line = fields.One2many('purchase.order.line', 'order_id', 'Order Lines', copy=True)
Run Code Online (Sandbox Code Playgroud)
我如上所述覆盖了字段order_line,但没有任何反应
odoo-8 ×12
odoo ×8
openerp ×5
python ×5
odoo-10 ×4
odoo-9 ×3
odoo-view ×2
python-2.7 ×2
attributes ×1
openerp-7 ×1
openerp-8 ×1
qweb ×1
report ×1
wkhtmltopdf ×1