我已经使用左上角的EDIT按钮对ODOO网站的主页进行了一些编辑.过了一段时间,我决定通过将XML模板继承到我的模块并在模板中完成更改来对主页进行一些更改.但这些变化并未在网页中反映出来.我在ODOO的网站建设者上定制模板时多次遇到这个问题.我注意到这些更改直接应用于XML视图,可以看到,Settings->Technical Settings->User Interface->Views即使模块已升级,也不会更改为以前的状态.在这种情况下,有什么方法可以通过在我的模块中继承模板来自定义模板吗?自定义适用于我在网站构建器中未进行任何编辑的所有模板.
我有一个字段,我想计算它的更改价值,但我不希望用户修改它。
如果我将字段设置为readonly = 1或editable = 0,则不会存储该值。
我正在尝试为发票设置全局折扣
class account_invoice(models.Model):
_inherit = "account.invoice"
global_discount_p = fields.Float('Descuento porcentaje')
global_discount = fields.Float('Descuento')
neto = fields.Float('Neto')
@api.one
@api.depends('invoice_line.price_subtotal', 'tax_line.amount','global_discount_p')
def _compute_amount(self):
ret = super(account_invoice,self)._compute_amount()
if self.type == 'in_invoice':
self.neto = self.amount_untaxed
discount = self.global_discount_p/100
self.global_discount = self.neto * discount
self.amount_untaxed = self.neto - self.global_discount
for line in self.tax_line:
line.base = self.amount_untaxed
line.amount = line.amount - (line.amount * discount)
self.amount_tax = sum(line.amount for line in self.tax_line)
self.amount_total = self.amount_untaxed + self.amount_tax
return ret
Run Code Online (Sandbox Code Playgroud)
并在布局中:
<xpath …Run Code Online (Sandbox Code Playgroud) 我想在odoo中存储配置数据,我需要存储3个'account.journal'的引用.模型在数据库中创建,视图显示在配置基础菜单中,当我按下APPLY按钮时数据存储在数据库中但是当我重新加载菜单时数据未显示
代码使用:
from openerp import fields, models, osv, api, _
class Configuration(models.TransientModel):
_inherit = 'res.config.settings'
_name = 'transporte_carta_de_porte.config.settings'
ft_mercaderia = fields.Many2one(
'account.journal',string='Debito ft mercaderia',
help="Diario de ajuste al transportista por faltante de mercaderia")
ade_transportista = fields.Many2one(
'account.journal',string='Debito por adelanto transportista',
help="Diario de debito al transportista por faltante de adelanto")
ade_proveedor = fields.Many2one(
'account.journal',string='Debito por adelanto proveedor',
help="Diario de debito por adelanto en la cuenta del proveedor de combustible",)
Run Code Online (Sandbox Code Playgroud)
布局
<record id="view_tcp_config_settings" model="ir.ui.view">
<field name="name">TCP settings</field>
<field name="model">transporte_carta_de_porte.config.settings</field>
<field name="arch" type="xml"> …Run Code Online (Sandbox Code Playgroud) 我正在使用Odoo ERP,我想限制从生成SQL查询中的字典列表返回无值.
form_data = self.read(cr, uid, ids, ['start_date','end_date'], context=context)[0]
sql = "select i.date_invoice, i.number, (select name from res_partner where id=i.partner_id) as partner,i.currency_id, (select name from res_currency where id=i.currency_id) as currency, (select description from account_tax where name=t.name), t.amount, t.base, (t.amount+t.base) as total from account_invoice i, account_invoice_tax t where t.invoice_id = i.id and i.state = 'open' and i.type = 'out_invoice' and i.date_invoice >= '%s' and i.date_invoice <= '%s' order by t.name"%(form_data['start_date'],form_data['end_date'])
cr.execute(sql)
data = cr.dictfetchall()
Run Code Online (Sandbox Code Playgroud)
生成结果:
data=[
{'currency_id': 38,
'description': u'GST 7%', …Run Code Online (Sandbox Code Playgroud) 我在eclipse IDE上使用odoo8和python 2.7.9(64位).Python软件已损坏,所以我不得不重新安装它.现在我正面临这个新问题ImportError: No module named win32service
我的Odoo v8模块上有这个代码:
@api.multi
def button_generate_wh_doc(self):
context = self._context
partner = self.env['res.partner']
res = {}
for inv in self:
view_id = self.env['ir.ui.view'].search([
('name', '=', 'account.invoice.wh.iva.customer')])
context.update({
'invoice_id': inv.id,
'type': inv.type,
'default_partner_id': partner._find_accounting_partner(
inv.partner_id).id,
'default_name': inv.name or inv.number,
'view_id': view_id,
})
res = {
'name': _('Withholding vat customer'),
'type': 'ir.actions.act_window',
'res_model': 'account.wh.iva',
'view_type': 'form',
'view_id': False,
'view_mode': 'form',
'nodestroy': True,
'target': 'current',
'domain': "[('type', '=', '" + inv.type + "')]",
'context': context
}
return res
Run Code Online (Sandbox Code Playgroud)
这是一个按钮动作,但当我点击它时它会抛出我:
File "/home/user/odoov8/odoo-venezuela/l10n_ve_withholding_iva/model/invoice.py", line 427, in button_generate_wh_doc …Run Code Online (Sandbox Code Playgroud) 如何在qweb报告中获取公司信息?我已经添加了
<t t-call="report.external_layout">
--------------
--------------
<span t-field="company.partner_id.street"/>
</t>
Run Code Online (Sandbox Code Playgroud)
到我的报告,但我得到这个错误
QWebException:"'NoneType'对象在评估'company.partner_id'时没有属性'partner_id'"
在销售订单模块中,我创建了一个新的自定义表单视图,在sale.py文件中我创建了一个新字段'is_sample'
'is_sample': fields.boolean("Specimen Order", store=False),
Run Code Online (Sandbox Code Playgroud)
我想从xml代码设置其默认值,以便它不会在默认窗体视图中受到影响.我试过四种方式,
1)<field name="is_sample" eval="True"/>
2)<field name="is_sample" domain="[('is_sample','=',True)]"/>
3)<record id="action_specimen_orders" model="ir.actions.act_window">
<field name="type">ir.actions.act_window</field>
<field name="context">{'is_sample': 'True'}</field>
...
4)<record id="action_specimen_orders" model="ir.actions.act_window">
<field name="type">ir.actions.act_window</field>
<field name="domain">[('is_sample','=','True')]</field>
...
Run Code Online (Sandbox Code Playgroud) 我正在继承project.project模块,我在其中添加了多个Many2many字段:'买家','卖家','联系人'等等.所有与res.partner相关.知道我何时向其中一个字段添加多个记录,例如添加一些买家.这些买家也会自动填写卖家,联系人字段.
任何想法如何防止这种情况,我理解为什么会发生这种情况,因为many2many创建了一个包含project_id和res_partner_id的表,并且不知道它是从卖家,买家或联系人字段创建的.
提前致谢.
我想隐藏某些用户的字段.
我试过这个:
<field name="note_project" attrs="{'invisible': [('members','=',user.id)]}"/>
Run Code Online (Sandbox Code Playgroud)
我的尝试不起作用.