Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

自动生成编码问题,求解答,谢谢!



  • 现在编码可以自动生产(用的系统自带的序号动作),但是想让编码每月自动从0001开始,目前用odoo11开发,求解决!谢谢!



  • 好像有类似的模块,https://github.com/osbzr/gooderp_addons/blob/master/ir_sequence_autoreset/ir_sequence.py 这个应该能满足你的需求,只不过是odoo10🤓 🤓 🤓 🤓



  • 起个cron job,

    每月月底自动把 sequence 的计数清零



  • @siyuan自动生成编码问题,求解答,谢谢! 中说:

    cron job

    cron job 不适合去做一些比较严格的操作,并不是很稳定。



  • @静静 这个是你们重写了原代码吗?
    不知道怎么用!
    求指点一下!!



  • @siyuan 你是说再写一个自动化的动作来每月清零操作吗?



  • @小杜 这是个模块,你先下载下来,试用一下看看能不能达到你的要求。。。



  • @小杜 对,或者你可以用 linux 的 cron job,每月0点定时执行一个脚本,

    脚本内容是连接数据库,将序号清零



  • @静静自动生成编码问题,求解答,谢谢! 中说:

    你先下载下来,试用一下看看能不能达到你的要求。。。

    不行啊,安装报错!



  • @小杜 😕 😕 😕 不说报什么错。那谁也帮不了你



  • @小杜 开源的好处是相关的开源模块,方案多。自行选择或者修改成适合自己的。你自己选择吧,



  • @静静自动生成编码问题,求解答,谢谢! 中说:

    选择或者修改成适合自己

    不好意思啊,忘记了!报找不到哪个字段!错误:
    Odoo Server Error

    Traceback (most recent call last):
    File "D:\Works\odoo\odoo\models.py", line 1036, in _validate_fields
    check(self)
    File "D:\Works\odoo\odoo\addons\base\ir\ir_ui_view.py", line 335, in _check_xml
    self.postprocess_and_fields(view.model, view_doc, view.id)
    File "D:\Works\odoo\odoo\addons\base\ir\ir_ui_view.py", line 1042, in postprocess_and_fields
    self.raise_view_error(message, view_id)
    File "D:\Works\odoo\odoo\addons\base\ir\ir_ui_view.py", line 503, in raise_view_error
    raise ValueError(message)
    ValueError: 字段auto_reset不存在

    错误的上下文:
    视图 ir.sequence form
    [view_id: 883, xml_id: 不适用, model: ir.sequence, parent_id: 55]

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "D:\Works\odoo\odoo\tools\convert.py", line 744, in parse
    self._tags[rec.tag](rec, de, mode=mode)
    File "D:\Works\odoo\odoo\tools\convert.py", line 654, in _tag_record
    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
    File "D:\Works\odoo\odoo\addons\base\ir\ir_model.py", line 1476, in _update
    record = record.create(values)
    File "D:\Works\enterprise\web_studio\models\studio_mixin.py", line 18, in create
    res = super(StudioMixin, self).create(vals)
    File "D:\Works\odoo\odoo\addons\base\ir\ir_ui_view.py", line 398, in create
    return super(View, self).create(self._compute_defaults(values))
    File "D:\Works\odoo\odoo\models.py", line 3381, in create
    self._fields[key].determine_inverse(record)
    File "D:\Works\odoo\odoo\fields.py", line 1071, in determine_inverse
    getattr(records, self.inverse)()
    File "D:\Works\odoo\odoo\addons\base\ir\ir_ui_view.py", line 266, in _inverse_arch
    view.write(data)
    File "D:\Works\enterprise\web_studio\models\studio_mixin.py", line 27, in write
    res = super(StudioMixin, self).write(vals)
    File "D:\Works\odoo\odoo\addons\base\ir\ir_ui_view.py", line 414, in write
    return super(View, self).write(self._compute_defaults(vals))
    File "D:\Works\odoo\odoo\models.py", line 3090, in write
    self._write(old_vals)
    File "D:\Works\odoo\odoo\models.py", line 3256, in _write
    self._validate_fields(vals)
    File "D:\Works\odoo\odoo\models.py", line 1040, in validate_fields
    raise ValidationError("%s\n\n%s" % (
    ("Error while validating constraint"), tools.ustr(e)))
    odoo.exceptions.ValidationError: ('constraint 检查错误\n\n字段auto_reset不存在\n\n错误的上下文:\n视图 ir.sequence form\n[view_id: 883, xml_id: 不适用, model: ir.sequence, parent_id: 55]', None)

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "D:\Works\odoo\odoo\http.py", line 650, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
    File "D:\Works\odoo\odoo\http.py", line 310, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
    File "D:\Works\odoo\odoo\tools\pycompat.py", line 87, in reraise
    raise value
    File "D:\Works\odoo\odoo\http.py", line 692, in dispatch
    result = self._call_function(**self.params)
    File "D:\Works\odoo\odoo\http.py", line 342, in _call_function
    return checked_call(self.db, *args, **kwargs)
    File "D:\Works\odoo\odoo\service\model.py", line 97, in wrapper
    return f(dbname, *args, **kwargs)
    File "D:\Works\odoo\odoo\http.py", line 335, in checked_call
    result = self.endpoint(*a, **kw)
    File "D:\Works\odoo\odoo\http.py", line 936, in call
    return self.method(*args, **kw)
    File "D:\Works\odoo\odoo\http.py", line 515, in response_wrap
    response = f(*args, **kw)
    File "D:\Works\odoo\addons\web\controllers\main.py", line 935, in call_button
    action = self._call_kw(model, method, args, {})
    File "D:\Works\odoo\addons\web\controllers\main.py", line 923, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
    File "D:\Works\odoo\odoo\api.py", line 689, in call_kw
    return call_kw_multi(method, model, args, kwargs)
    File "D:\Works\odoo\odoo\api.py", line 680, in call_kw_multi
    result = method(recs, *args, **kwargs)
    File "", line 2, in button_immediate_install
    File "D:\Works\odoo\odoo\addons\base\module\module.py", line 71, in check_and_log
    return method(self, *args, **kwargs)
    File "D:\Works\odoo\odoo\addons\base\module\module.py", line 448, in button_immediate_install
    return self._button_immediate_function(type(self).button_install)
    File "D:\Works\odoo\odoo\addons\base\module\module.py", line 541, in _button_immediate_function
    modules.registry.Registry.new(self._cr.dbname, update_module=True)
    File "D:\Works\odoo\odoo\modules\registry.py", line 85, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
    File "D:\Works\odoo\odoo\modules\loading.py", line 343, in load_modules
    loaded_modules, update_module)
    File "D:\Works\odoo\odoo\modules\loading.py", line 242, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
    File "D:\Works\odoo\odoo\modules\loading.py", line 156, in load_module_graph
    _load_data(cr, module_name, idref, mode, kind='data')
    File "D:\Works\odoo\odoo\modules\loading.py", line 94, in _load_data
    tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
    File "D:\Works\odoo\odoo\tools\convert.py", line 791, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
    File "D:\Works\odoo\odoo\tools\convert.py", line 852, in convert_xml_import
    obj.parse(doc.getroot(), mode=mode)
    File "D:\Works\odoo\odoo\tools\convert.py", line 741, in parse
    self.parse(rec, mode)
    File "D:\Works\odoo\odoo\tools\convert.py", line 751, in parse
    exc_info[2]
    File "D:\Works\odoo\odoo\tools\pycompat.py", line 86, in reraise
    raise value.with_traceback(tb)
    File "D:\Works\odoo\odoo\tools\convert.py", line 744, in parse
    self._tags[rec.tag](rec, de, mode=mode)
    File "D:\Works\odoo\odoo\tools\convert.py", line 654, in _tag_record
    id = self.env(context=rec_context)['ir.model.data']._update(rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode)
    File "D:\Works\odoo\odoo\addons\base\ir\ir_model.py", line 1476, in _update
    record = record.create(values)
    File "D:\Works\enterprise\web_studio\models\studio_mixin.py", line 18, in create
    res = super(StudioMixin, self).create(vals)
    File "D:\Works\odoo\odoo\addons\base\ir\ir_ui_view.py", line 398, in create
    return super(View, self).create(self._compute_defaults(values))
    File "D:\Works\odoo\odoo\models.py", line 3381, in create
    self._fields[key].determine_inverse(record)
    File "D:\Works\odoo\odoo\fields.py", line 1071, in determine_inverse
    getattr(records, self.inverse)()
    File "D:\Works\odoo\odoo\addons\base\ir\ir_ui_view.py", line 266, in _inverse_arch
    view.write(data)
    File "D:\Works\enterprise\web_studio\models\studio_mixin.py", line 27, in write
    res = super(StudioMixin, self).write(vals)
    File "D:\Works\odoo\odoo\addons\base\ir\ir_ui_view.py", line 414, in write
    return super(View, self).write(self._compute_defaults(vals))
    File "D:\Works\odoo\odoo\models.py", line 3090, in write
    self._write(old_vals)
    File "D:\Works\odoo\odoo\models.py", line 3256, in _write
    self._validate_fields(vals)
    File "D:\Works\odoo\odoo\models.py", line 1040, in validate_fields
    raise ValidationError("%s\n\n%s" % (
    ("Error while validating constraint"), tools.ustr(e)))
    odoo.tools.convert.ParseError: "constraint 检查错误

    字段auto_reset不存在

    错误的上下文:
    视图 ir.sequence form
    [view_id: 883, xml_id: 不适用, model: ir.sequence, parent_id: 55]
    None" while parsing file:/d:/works/myaddons/ir_sequence_autoreset/ir_sequence.xml:5, near

    ir.sequence
    form











  • @小杜自动生成编码问题,求解答,谢谢! 中说:

    auto_reset

    添加新模块,你都不重启服务器的?



  • 里面的10的代码我改了一下,现在可以运行了!
    谢谢!