跳至内容
菜单
此问题已终结

Dear All,


Odoo V16


I try to inherit a wizard but I have the below error: 

TypeError: transforms the transient model 'sale.advance.payment.inv' into a non-transient model. That class should either inherit from TransientModel, or set a different '_name'. 




I don't inherit XML file, I want only to override the function.


I try to inherit this code:

class SaleAdvancePaymentInv(models.TransientModel):
​​ _name = 'sale.advance.payment.inv'
​_description = "Sales Advance Payment Invoice"

​def create_invoices(self):
​​​​​self._create_invoices(self.sale_order_ids)
​​​​...​
return {'type': 'ir.actions.act_window_close'}


My code:

class SaleAdvancePaymentInvInherited(models.TransientModel):
​# Also, I try without using _name
​_name = 'sale.advance.payment.inv.inherited'
​_inherit = "sale.advance.payment.inv"

​def create_invoices(self)
:
​​self._create_invoices(self.sale_order_ids)

​logging.info('Hello function')
​...
​return {'type': 'ir.actions.act_window_close'}


形象
丢弃
最佳答案

Hi,

You can remove the _name attribute from the code and try as follows:

class SaleAdvancePaymentInv(models.TransientModel):
_inherit = "sale.advance.payment.inv"

def _prepare_invoice_values(self, order, so_line):
res = super()._prepare_invoice_values(order, so_line)
if order.l10n_in_journal_id:
res['journal_id'] = order.l10n_in_journal_id.id
if order.country_code == 'IN':
res['l10n_in_gst_treatment'] = order.l10n_in_gst_treatment
if order.l10n_in_reseller_partner_id:
res['l10n_in_reseller_partner_id'] = order.l10n_in_reseller_partner_id
return res

Sample from: https://github.com/odoo/odoo/blob/16.0/addons/l10n_in_sale/wizard/sale_make_invoice_advance.py

Thanks

形象
丢弃
编写者

I have the same error.

please make sure to restart or ensure that the service is getting restarted and proper dependency is added

编写者

I just restarted my computer. The IDE was stuck. Sad

最佳答案

Hi, you can follow following link for this:

https://youtu.be/oMnHpHH54QU

Thanks

形象
丢弃
最佳答案

Hi

Try the code,

from odoo import models

class SaleAdvancePaymentInv(models.TransientModel):
    _inherit = 'sale.advance.payment.inv'

    def create_invoices(self):
        result = super(SaleAdvancePaymentInv, self).create_invoices()
       
        # Add your custom logic here
       
        return result

形象
丢弃
相关帖文 回复 查看 活动
0
1月 24
1658
1
4月 24
1643
1
11月 24
4017
1
5月 23
3491
0
2月 25
3225