I get this error when i try to create invoice.
Odoo Server Error
Traceback (most recent call last): File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/odoo/http.py", line 656, in _handle_exception return super(JsonRequest, self)._handle_exception(exception) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/odoo/http.py", line 314, in _handle_exception raise pycompat.reraise(type(exception), exception, sys.exc_info()[2]) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/odoo/tools/pycompat.py", line 87, in reraise raise value File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/odoo/http.py", line 698, in dispatch result = self._call_function(**self.params) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/odoo/http.py", line 346, in _call_function return checked_call(self.db, *args, **kwargs) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/odoo/service/model.py", line 97, in wrapper return f(dbname, *args, **kwargs) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/odoo/http.py", line 339, in checked_call result = self.endpoint(*a, **kw) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/odoo/http.py", line 941, in __call__ return self.method(*args, **kw) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/odoo/http.py", line 519, in response_wrap response = f(*args, **kw) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/addons/web/controllers/main.py", line 966, in call_button action = self._call_kw(model, method, args, {}) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/addons/web/controllers/main.py", line 954, in _call_kw return call_kw(request.env[model], method, args, kwargs) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/odoo/api.py", line 759, in call_kw return _call_kw_multi(method, model, args, kwargs) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/odoo/api.py", line 746, in _call_kw_multi result = method(recs, *args, **kwargs) File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/env/env_zameen/addons/rsms/real_estate/models/file.py", line 353, in create_invoice invoice.action_invoice_open() File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/addons/sale/models/account_invoice.py", line 59, in action_invoice_open res = super(AccountInvoice, self).action_invoice_open() File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/thirdparty/financials/fiscal/models/fiscal_year.py", line 256, in action_invoice_open return super(AccountInvoice, self).action_invoice_open() File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/addons/account/models/account_invoice.py", line 988, in action_invoice_open to_open_invoices.action_move_create() File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/thirdparty/financials/account_asset/models/account_invoice.py", line 33, in action_move_create result = super(AccountInvoice, self).action_move_create() File "/home/syedhamza/custom/programming/enviornments/odoo/odoo12/src/odoo/addons/account/models/account_invoice.py", line 1341, in action_move_create move.post(invoice = inv) TypeError: post() got an unexpected keyword argument 'invoice'
my code:
@api.multi
def create_invoice(self):
# check duplicity
list_of_product_id = [x.product_id.id for x in self.file_payment_ids]
for i in list_of_product_id:
if list_of_product_id.count(i) > 1:
raise ValidationError(_("Duplicity of products are not allowed"))
if self.file_payment_ids:
prod = [(0, 0, {
'product_id': rec.product_id.id,
'name': rec.product_id.name,
'account_id': rec.product_id.property_account_income_id.id,
# 'price_unit': rec.value if rec.payment_type == 'fix' else [self.sale_amount * rec.value / 100][0]
'price_unit': rec.initial_payment,
# 'is_fully_paid': rec.is_fully_paid
}) for rec in self.file_payment_ids]
invoice = self.env['account.invoice'].create({
'file_id': self, # this id is just for invoice create method i will extract this field from there and push remaining values
'name': self.name,
'type' : 'out_invoice',
'user_id':self.user_id.id,
'partner_id': self.membership_id.id,
'account_id': self.membership_id.property_account_receivable_id.id,
'property_invoice_type': 'initial_payment',
'date_invoice': self.booking_date,
'date_due': self.booking_date,
'invoice_line_ids': prod
})
invoice.action_invoice_open()
self.payment_states = 'open'
self.history_log('First Owner', invoice.create_date, self.membership_id.id,self.env.user.company_id.partner_id.id)
self.initial_invoice = False
self.env['confirmation'].confirmation_popup('Invoice')
Updated my Question:
here's the post method
_inherit = "account.move"
@api.multi
def post(self):
date_jv = self.date
fiscal_year_obj = self.env['fiscal.year'].search([('start_date', '<=', date_jv), ('end_date', '>=', date_jv)])
fiscal_month_obj = self.env['fiscal.month'].search(
[('open_close', '=', False), ('start_date', '<=', date_jv), ('end_date', '>=', date_jv)])
if date_jv:
inv_date = datetime.strptime(date_jv, "%Y-%m-%d")
else:
raise ValidationError(
"Please enter journal entry date!")
invdate_year = inv_date.year
if fiscal_year_obj:
if fiscal_year_obj[0].state != 'closed':
if fiscal_month_obj:
if fiscal_month_obj[0].state != 'closed':
return super(AccountMove, self).post()
else:
raise ValidationError(
"You are trying to access %r fiscal month that is already closed" % fiscal_month_obj[
0].name)
else:
raise ValidationError("month not found")
else:
raise ValidationError(
"You are trying to access %r fiscal year that is already closed" % fiscal_year_obj[0].name)
else:
raise ValidationError("year not found")
I don't know what is wrong. Any help ?
Search for the post method in your custom module and upload the method code in your question.