Skip to Content
Menu
This question has been flagged

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'}


Avatar
Discard
Best Answer

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

Avatar
Discard
Author

I have the same error.

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

Author

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

Best Answer

Hi, you can follow following link for this:

https://youtu.be/oMnHpHH54QU

Thanks

Avatar
Discard
Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
0
Jan 24
1023
1
Apr 24
1079
1
Nov 24
3294
1
May 23
2814
0
Feb 25
2799