新增product.template字段后,升级purchase模块出错
已解决
Odoo 开发与实施交流
-
请教大神:
我继承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>
-
你的模块的
__manifest__.py
文件中的depends
应该有问题。能贴出来看一下吗?
另外,你贴代码的时候,可以把代码包在三个反点中,比如``` mycode ``` ,这样就会保持格式,并且有语法高亮。 -
你的模块的
__manifest__.py
文件中的depends
应该有问题。能贴出来看一下吗?
另外,你贴代码的时候,可以把代码包在三个反点中,比如``` mycode ``` ,这样就会保持格式,并且有语法高亮。 -
在purchase模块的__manifest__.py depend中增加新增的模块后,问题解决了。
感谢大神指导
-
@floatingdudu 在 新增product.template字段后,升级purchase模块出错 中说:
在purchase模块的__manifest__.py depend中增加新增的模块后,问题解决了。
感谢大神指导
问题应该没有解决:beaming_face_with_smiling_eyes: 。你新创建了一个模块,然后还要在原生模块里添加对你的新模块的依赖?完全不懂这个逻辑。
-