Odoo 17,post_方法中软参数的问题

问题描述 投票:0回答:1

我做了一个在Odoo 17的_post方法上运行的开发,当我开发它时没有问题,直到我将它安装在新的底座上时,在制作产品收据时才开始出现此错误在购买中(我的开发与购买无关,我从来没有继承购买模块,我不知道为什么当时会发生这种情况)。 不用说,当我调用 _post 方法时,我总是传递“soft”参数,我从来没有忘记它,这就是为什么我发现这个问题如此令人沮丧。

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
  File "D:\Documentos\odoo-17\odoo\odoo\http.py", line 1783, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documentos\odoo-17\odoo\odoo\service\model.py", line 133, in retrying
    result = func()
             ^^^^^^
  File "D:\Documentos\odoo-17\odoo\odoo\http.py", line 1810, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documentos\odoo-17\odoo\odoo\http.py", line 2014, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documentos\odoo-17\odoo\odoo\addons\base\models\ir_http.py", line 222, in _dispatch
    result = endpoint(**request.params)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documentos\odoo-17\odoo\odoo\http.py", line 759, in route_wrapper
    result = endpoint(self, *args, **params_ok)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\documentos\odoo-17\odoo\addons\web\controllers\dataset.py", line 28, in call_button
    action = self._call_kw(model, method, args, kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\documentos\odoo-17\odoo\addons\web\controllers\dataset.py", line 20, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documentos\odoo-17\odoo\odoo\api.py", line 468, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Documentos\odoo-17\odoo\odoo\api.py", line 453, in _call_kw_multi
    result = method(recs, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\documentos\odoo-17\odoo\addons\stock\models\stock_picking.py", line 1156, in button_validate
    pickings_to_backorder.with_context(cancel_backorder=False)._action_done()
  File "d:\documentos\odoo-17\odoo\addons\sale_stock\models\stock.py", line 109, in _action_done
    res = super()._action_done()
          ^^^^^^^^^^^^^^^^^^^^^^
  File "d:\documentos\odoo-17\odoo\addons\stock\models\stock_picking.py", line 989, in _action_done
    todo_moves._action_done(cancel_backorder=self.env.context.get('cancel_backorder'))
  File "d:\documentos\odoo-17\odoo\addons\stock_account\models\stock_move.py", line 293, in _action_done
    stock_valuation_layers._validate_accounting_entries()
  File "d:\documentos\odoo-17\odoo\addons\stock_account\models\stock_valuation_layer.py", line 77, in _validate_accounting_entries
    account_moves._post()
TypeError: AccountMove._post() missing 1 required positional argument: 'soft'

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
    RPC_ERROR
        at makeErrorFromResponse (http://localhost:8069/web/assets/e226aa6/web.assets_web.min.js:2888:163)
        at XMLHttpRequest.<anonymous> (http://localhost:8069/web/assets/e226aa6/web.assets_web.min.js:2892:13)

这是我的代码:

def _post(self, soft):
    facturas_especiales = self.filtered(lambda factura: factura.factura_especial)
    for factura_especial in facturas_especiales:
        if not factura_especial.journal_id.facturas_especiales:
            raise ValidationError("El diario no está configurado para trabajar con facturas especiales")

move_types = ["fact", "fact_cambiaria", "fact_exportacion", "out_refund"]
por_certificar = self.filtered(
    lambda factura: factura.journal_id.facturacion_activa
    and (factura.tipo_factura in move_types or factura.factura_especial or not factura.tipo_factura)
    and not factura.certificada
)

for factura in por_certificar:
    if self.company_id.proveedor == "infile":
        infile.facturacion_electronica(self, factura)
    elif self.company_id.proveedor == "cofidi":
        cofidi.facturacion_electronica(self, factura)

continuar_movimientos = self.filtered(lambda fact: not fact.certificacion_error)
return super(AccountMove, continuar_movimientos)._post(soft)
python odoo odoo-17 pyxml
1个回答
0
投票

将关键字参数切换为位置参数可能是这里的问题。

Odoo 原创(例如在帐户模块中):

def _post(self, soft=True):

你的:

def _post(self, soft):

购买模块对该方法的调用可能会使用关键字参数来调用它,这将解释错误消息“TypeError:AccountMove._post()缺少 1 个必需的位置参数:'soft'”。

只需将方法签名更改为原始方法签名,一切都会好起来的。

© www.soinside.com 2019 - 2024. All rights reserved.