问题已经解决,格式有点问题
floatingdudu
-
为什么扩展模块的方法不工作? -
为什么扩展模块的方法不工作?@floatingdudu 在 为什么扩展模块的方法不工作? 中说:
@floatingdudu 在 为什么扩展模块的方法不工作? 中说:
product_qty&price_unit并按代码没有赋值
敲错了,应为: product_qty&price_unit没有按代码赋值是否和manifest/security设置有关呢?
-
为什么扩展模块的方法不工作?@floatingdudu 在 为什么扩展模块的方法不工作? 中说:
product_qty&price_unit并按代码没有赋值
敲错了,应为: product_qty&price_unit没有按代码赋值 -
为什么扩展模块的方法不工作?大神好!
我建了个简单的采购订单扩展模块,代码如下。
重启odoo后,没有报错,修改视图后在采购订单行中可以看到新增的这几个字段。但是方法没有执行:
product_qty&price_unit并按代码没有赋值。将下面的代码简单改为对myprice字段赋值或提示告警,方法一样没有反应。'''
from datetime import datetime
from dateutil.relativedelta import relativedeltafrom odoo import api, fields, models, SUPERUSER_ID, _
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
from odoo.tools.float_utils import float_compare
from odoo.exceptions import UserError, AccessError
from odoo.tools.misc import formatLang
from odoo.addons import decimal_precision as dp
from odoo.exceptions import ValidationError
from itertools import groupbyclass PurchaseOrderLine(models.Model):
""" Defines purchase oder """
_inherit = ['purchase.order.line']x_specification = fields.Char(related='product_id.prd_specification',string=u'规格') x_standard_price = fields.Float(related='product_id.standard_price',string=u'标准单价') myprice = fields.Float(string=u'标准单价1')
@api.onchange('product_id')
def onchange_product_id(self):
res = super(PurchaseOrderLine,
for rec in self:
rec.product_qty = 10 # will trigger _onchange_quantity() on returnreturn res
@api.onchange('product_qty', 'product_uom')
def _onchange_quantity(self):
res = super(PurchaseOrderLine, self)._onchange_quantity()
for rec in self:
rec.price_unit = 2.0return res
'''
-
新增product.template字段后,升级purchase模块出错在purchase模块的__manifest__.py depend中增加新增的模块后,问题解决了。
感谢大神指导
-
新增product.template字段后,升级purchase模块出错请教大神:
我继承product.template新增了prd_version字段,可以正常使用。但是当我升级purchase模块时,却提示找不到prd_version字段,错误信息如下。请问是什么原因?错误信息:
Odoo Server Error Traceback (most recent call last): File "F:\greenodoo12-win\odoo12\odoo\models.py", line 1108, in _validate_fields check(self) File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_ui_view.py", line 351, in _check_xml self.postprocess_and_fields(view.model, view_doc, view.id) File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_ui_view.py", line 1092, in postprocess_and_fields self.raise_view_error(message, view_id) File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_ui_view.py", line 545, in raise_view_error raise ValueError(message) ValueError: 字段`prd_version`不存在 错误的上下文: 视图 `product.template.purchase.button.inherit` [view_id: 1024, xml_id: purchase.view_product_template_purchase_buttons_from, model: product.template, parent_id: 368] During handling of the above exception, another exception occurred: Traceback (most recent call last): File "F:\greenodoo12-win\odoo12\odoo\tools\convert.py", line 757, in parse self._tags[rec.tag](rec, de, mode=mode) File "F:\greenodoo12-win\odoo12\odoo\tools\convert.py", line 662, in _tag_record record = model.with_context(rec_context)._load_records([data], self.mode == 'update') File "F:\greenodoo12-win\odoo12\odoo\models.py", line 3784, in _load_records data['record'].write(data['values']) File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_ui_view.py", line 441, in write return super(View, self).write(self._compute_defaults(vals)) File "F:\greenodoo12-win\odoo12\odoo\models.py", line 3302, in write fields[0].determine_inverse(records) File "F:\greenodoo12-win\odoo12\odoo\fields.py", line 1094, in determine_inverse getattr(records, self.inverse)() File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_ui_view.py", line 275, in _inverse_arch view.write(data) File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_ui_view.py", line 441, in write return super(View, self).write(self._compute_defaults(vals)) File "F:\greenodoo12-win\odoo12\odoo\models.py", line 3265, in write self._write(store_vals) File "F:\greenodoo12-win\odoo12\odoo\models.py", line 3409, in _write self._validate_fields(vals) File "F:\greenodoo12-win\odoo12\odoo\models.py", line 1112, in _validate_fields raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e))) odoo.exceptions.ValidationError: ('constraint 检查错误\n\n字段`prd_version`不存在\n\n错误的上下文:\n视图 `product.template.purchase.button.inherit`\n[view_id: 1024, xml_id: purchase.view_product_template_purchase_buttons_from, model: product.template, parent_id: 368]', None) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "F:\greenodoo12-win\odoo12\odoo\http.py", line 654, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "F:\greenodoo12-win\odoo12\odoo\http.py", line 312, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "F:\greenodoo12-win\odoo12\odoo\tools\pycompat.py", line 87, in reraise raise value File "F:\greenodoo12-win\odoo12\odoo\http.py", line 696, in dispatch result = self._call_function(**self.params) File "F:\greenodoo12-win\odoo12\odoo\http.py", line 344, in _call_function return checked_call(self.db, *args, **kwargs) File "F:\greenodoo12-win\odoo12\odoo\service\model.py", line 97, in wrapper return f(dbname, *args, **kwargs) File "F:\greenodoo12-win\odoo12\odoo\http.py", line 337, in checked_call result = self.endpoint(*a, **kw) File "F:\greenodoo12-win\odoo12\odoo\http.py", line 939, in __call__ return self.method(*args, **kw) File "F:\greenodoo12-win\odoo12\odoo\http.py", line 517, in response_wrap response = f(*args, **kw) File "F:\greenodoo12-win\odoo12\addons\web\controllers\main.py", line 966, in call_button action = self._call_kw(model, method, args, {}) File "F:\greenodoo12-win\odoo12\addons\web\controllers\main.py", line 954, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "F:\greenodoo12-win\odoo12\odoo\api.py", line 749, in call_kw return _call_kw_multi(method, model, args, kwargs) File "F:\greenodoo12-win\odoo12\odoo\api.py", line 736, in _call_kw_multi result = method(recs, *args, **kwargs) File "<decorator-gen-67>", line 2, in button_immediate_upgrade File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_module.py", line 71, in check_and_log return method(self, *args, **kwargs) File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_module.py", line 596, in button_immediate_upgrade return self._button_immediate_function(type(self).button_upgrade) File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_module.py", line 535, in _button_immediate_function modules.registry.Registry.new(self._cr.dbname, update_module=True) File "F:\greenodoo12-win\odoo12\odoo\modules\registry.py", line 86, in new odoo.modules.load_modules(registry._db, force_demo, status, update_module) File "F:\greenodoo12-win\odoo12\odoo\modules\loading.py", line 417, in load_modules force, status, report, loaded_modules, update_module, models_to_check) File "F:\greenodoo12-win\odoo12\odoo\modules\loading.py", line 313, in load_marked_modules perform_checks=perform_checks, models_to_check=models_to_check File "F:\greenodoo12-win\odoo12\odoo\modules\loading.py", line 222, in load_module_graph load_data(cr, idref, mode, kind='data', package=package, report=report) File "F:\greenodoo12-win\odoo12\odoo\modules\loading.py", line 68, in load_data tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report) File "F:\greenodoo12-win\odoo12\odoo\tools\convert.py", line 801, in convert_file convert_xml_import(cr, module, fp, idref, mode, noupdate, report) File "F:\greenodoo12-win\odoo12\odoo\tools\convert.py", line 864, in convert_xml_import obj.parse(doc.getroot(), mode=mode) File "F:\greenodoo12-win\odoo12\odoo\tools\convert.py", line 763, in parse exc_info[2] File "F:\greenodoo12-win\odoo12\odoo\tools\pycompat.py", line 86, in reraise raise value.with_traceback(tb) File "F:\greenodoo12-win\odoo12\odoo\tools\convert.py", line 757, in parse self._tags[rec.tag](rec, de, mode=mode) File "F:\greenodoo12-win\odoo12\odoo\tools\convert.py", line 662, in _tag_record record = model.with_context(rec_context)._load_records([data], self.mode == 'update') File "F:\greenodoo12-win\odoo12\odoo\models.py", line 3784, in _load_records data['record'].write(data['values']) File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_ui_view.py", line 441, in write return super(View, self).write(self._compute_defaults(vals)) File "F:\greenodoo12-win\odoo12\odoo\models.py", line 3302, in write fields[0].determine_inverse(records) File "F:\greenodoo12-win\odoo12\odoo\fields.py", line 1094, in determine_inverse getattr(records, self.inverse)() File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_ui_view.py", line 275, in _inverse_arch view.write(data) File "F:\greenodoo12-win\odoo12\odoo\addons\base\models\ir_ui_view.py", line 441, in write return super(View, self).write(self._compute_defaults(vals)) File "F:\greenodoo12-win\odoo12\odoo\models.py", line 3265, in write self._write(store_vals) File "F:\greenodoo12-win\odoo12\odoo\models.py", line 3409, in _write self._validate_fields(vals) File "F:\greenodoo12-win\odoo12\odoo\models.py", line 1112, in _validate_fields raise ValidationError("%s\n\n%s" % (_("Error while validating constraint"), tools.ustr(e))) odoo.tools.convert.ParseError: "constraint 检查错误 字段`prd_version`不存在 错误的上下文: 视图 `product.template.purchase.button.inherit` [view_id: 1024, xml_id: purchase.view_product_template_purchase_buttons_from, model: product.template, parent_id: 368] None" while parsing file:/f:/greenodoo12-win/odoo12/addons/purchase/views/product_views.xml:68, near <record id="view_product_template_purchase_buttons_from" model="ir.ui.view"> <field name="name">product.template.purchase.button.inherit</field> <field name="model">product.template</field> <field name="inherit_id" ref="product.product_template_only_form_view"/> <field name="groups_id" eval="[(4, ref('purchase.group_purchase_user'))]"/> <field name="arch" type="xml"> <button name="toggle_active" position="before"> <button class="oe_stat_button" name="action_view_po" type="object" icon="fa-shopping-cart" attrs="{'invisible': [('purchase_ok', '=', False)]}" help="Purchased in the last 365 days"> <div class="o_field_widget o_stat_info"> <span class="o_stat_value"> <field name="purchased_product_qty" widget="statinfo" nolabel="1" class="mr4"/> <field name="uom_name"/> </span> <span class="o_stat_text">Purchased</span> </div> </button> </button> </field> </record>
-
Odoo 13如何实现对供应商分批/多次付款?请教大侠救急!
供应商一个订单的货物分多次送到。因此,一个订单需要付几次款给供应商。
比如9月付10W,10月付20W。
9月创建一个账单付款10W是ok的。
但10月再创建账单付款时,提示重复记录账单,无法操作。请问怎么处理?
-
如何设置收到客户全款后发货?请教一个小白问题:
如何设置订单在收到客户全款后才让发货?
网上说选择发货策略为"Payment Before Delivery",但是我的发货策略中没有这个选项。谢谢
-
如何修改产品/零件搜索视图以增加字段显示?问题已经解决.谢谢
-
如何修改产品/零件搜索视图以增加字段显示?请教大神:
在建立bom明细时,需要搜索并添加零件,这时会弹出下面的视图。
我想在这个视图上增加一个“料号”字段,并可根据料号进行检索,请问怎么做?谢谢
-
如何在BOM清单明细中增加编码字段?问题已经解决。谢谢digitalsatori
-
如何在BOM清单明细中增加编码字段?谢谢 digitalsatori大神回复!
刚试了下,貌似原有的py文件做任何修改后都会出异常。
我创建addon试试。第一次接触,建addon目前对我有点难了,本来想直接在原来的上面修改省点事情。 -
如何在BOM清单明细中增加编码字段?@floatingdudu 在 如何在BOM清单明细中增加编码字段? 中说:
谢谢 digitalsatori大神回复!
请问,是将上述语句加入到odoo\addons\mrp\models\mrp_bom.py中,然后再修改xml文件吗?我在mrp_bom.py中增加如上代码后,重启服务,出现如下错误:
Odoo Server Error
Traceback (most recent call last):
File "F:\greenodoo12-win\odoo12\odoo\api.py", line 1039, in get
value = self._data[key][field][record.id]
KeyError: 46During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "F:\greenodoo12-win\odoo12\odoo\fields.py", line 960, in get
value = record.env.cache.get(record, self)
File "F:\greenodoo12-win\odoo12\odoo\api.py", line 1041, in get
raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: ('product.template(46,).currency_id', None)During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "F:\greenodoo12-win\odoo12\odoo\http.py", line 654, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "F:\greenodoo12-win\odoo12\odoo\http.py", line 312, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "F:\greenodoo12-win\odoo12\odoo\tools\pycompat.py", line 87, in reraise
raise value
File "F:\greenodoo12-win\odoo12\odoo\http.py", line 696, in dispatch
result = self._call_function(**self.params)
File "F:\greenodoo12-win\odoo12\odoo\http.py", line 344, in _call_function
return checked_call(self.db, *args, **kwargs)
File "F:\greenodoo12-win\odoo12\odoo\service\model.py", line 97, in wrapper
return f(dbname, *args, **kwargs)
File "F:\greenodoo12-win\odoo12\odoo\http.py", line 337, in checked_call
result = self.endpoint(*a, **kw)
File "F:\greenodoo12-win\odoo12\odoo\http.py", line 939, in call
return self.method(*args, **kw)
File "F:\greenodoo12-win\odoo12\odoo\http.py", line 517, in response_wrap
response = f(*args, **kw)
File "F:\greenodoo12-win\odoo12\addons\web\controllers\main.py", line 904, in search_read
return self.do_search_read(model, fields, offset, limit, domain, sort)
File "F:\greenodoo12-win\odoo12\addons\web\controllers\main.py", line 926, in do_search_read
offset=offset or 0, limit=limit or False, order=sort or False)
File "F:\greenodoo12-win\odoo12\odoo\models.py", line 4532, in search_read
result = records.read(fields)
File "F:\greenodoo12-win\odoo12\odoo\models.py", line 2776, in read
values[name] = field.convert_to_read(record[name], record, use_name_get)
File "F:\greenodoo12-win\odoo12\odoo\models.py", line 5055, in getitem
return self._fields[key].get(self, type(self))
File "F:\greenodoo12-win\odoo12\odoo\fields.py", line 964, in get
self.determine_value(record)
File "F:\greenodoo12-win\odoo12\odoo\fields.py", line 1075, in determine_value
self.compute_value(recs)
File "F:\greenodoo12-win\odoo12\odoo\fields.py", line 1031, in compute_value
self._compute_value(records)
File "F:\greenodoo12-win\odoo12\odoo\fields.py", line 1022, in _compute_value
getattr(records, self.compute)()
File "F:\greenodoo12-win\odoo12\addons\product\models\product_template.py", line 179, in _compute_currency_id
main_company = self.env['res.company']._get_main_company()
AttributeError: 'res.company' object has no attribute '_get_main_company' -
如何在BOM清单明细中增加编码字段?谢谢 digitalsatori大神回复!
请问,是将上述语句加入到odoo\addons\mrp\models\mrp_bom.py中,然后再修改xml文件吗? -
如何在BOM清单明细中增加编码字段?请教大神:产品/零件中有个barcode字段,录入了产品/零件的编码(一串数字)。创建清单明细时,我想增加一个编码字段,让该字段内容为产品/零件的barcode字段的内容。这样我建立清单明显时,选择相应的零件,自动带出barcode到编码字段。
或者说,在创建清单明细时,希望自动带出所选零件/产品的一些字段的内容,比如barcode、单价等。
该怎么弄呢?谢谢