Skip to Content
Odoo Menu
  • Zaloguj się
  • Wypróbuj za darmo
  • Aplikacje
    Finanse
    • Księgowość
    • Fakturowanie
    • Wydatki
    • Arkusz kalkulacyjny (BI)
    • Dokumenty
    • Podpisy
    Sprzedaż
    • CRM
    • Sprzedaż
    • PoS Sklep
    • PoS Restauracja
    • Subskrypcje
    • Wypożyczalnia
    Strony Internetowe
    • Kreator Stron Internetowych
    • eCommerce
    • Blog
    • Forum
    • Czat na Żywo
    • eLearning
    Łańcuch dostaw
    • Magazyn
    • Produkcja
    • PLM
    • Zakupy
    • Konserwacja
    • Jakość
    Zasoby Ludzkie
    • Pracownicy
    • Rekrutacja
    • Urlopy
    • Ocena pracy
    • Polecenia Pracownicze
    • Flota
    Marketing
    • Marketing Społecznościowy
    • E-mail Marketing
    • SMS Marketing
    • Wydarzenia
    • Automatyzacja Marketingu
    • Ankiety
    Usługi
    • Projekt
    • Ewidencja czasu pracy
    • Usługi Terenowe
    • Helpdesk
    • Planowanie
    • Spotkania
    Produktywność
    • Dyskusje
    • Zatwierdzenia
    • IoT
    • VoIP
    • Baza wiedzy
    • WhatsApp
    Aplikacje trzecich stron Studio Odoo Odoo Cloud Platform
  • Branże
    Sprzedaż detaliczna
    • Księgarnia
    • Sklep odzieżowy
    • Sklep meblowy
    • Sklep spożywczy
    • Sklep z narzędziami
    • Sklep z zabawkami
    Żywienie i hotelarstwo
    • Bar i Pub
    • Restauracja
    • Fast Food
    • Pensjonat
    • Dystrybutor napojów
    • Hotel
    Agencja nieruchomości
    • Agencja nieruchomości
    • Biuro architektoniczne
    • Budowa
    • Zarządzanie nieruchomościami
    • Ogrodnictwo
    • Stowarzyszenie właścicieli nieruchomości
    Doradztwo
    • Biuro księgowe
    • Partner Odoo
    • Agencja marketingowa
    • Kancelaria prawna
    • Agencja rekrutacyjna
    • Audyt i certyfikacja
    Produkcja
    • Tekstylia
    • Metal
    • Meble
    • Jedzenie
    • Browar
    • Prezenty firmowe
    Zdrowie & Fitness
    • Klub sportowy
    • Salon optyczny
    • Centrum fitness
    • Praktycy Wellness
    • Apteka
    • Salon fryzjerski
    Transakcje
    • Złota rączka
    • Wsparcie Sprzętu IT
    • Systemy energii słonecznej
    • Szewc
    • Firma sprzątająca
    • Usługi HVAC
    Inne
    • Organizacja non-profit
    • Agencja Środowiskowa
    • Wynajem billboardów
    • Fotografia
    • Leasing rowerów
    • Sprzedawca oprogramowania
    Przeglądaj wszystkie branże
  • Community
    Ucz się
    • Samouczki
    • Dokumentacja
    • Certyfikacje
    • Szkolenie
    • Blog
    • Podcast
    Pomóż w nauce innym
    • Program Edukacyjny
    • Scale Up! Gra biznesowa
    • Odwiedź Odoo
    Skorzystaj z oprogramowania
    • Pobierz
    • Porównaj edycje
    • Wydania
    Współpracuj
    • Github
    • Forum
    • Wydarzenia
    • Tłumaczenia
    • Zostań partnerem
    • Usługi dla partnerów
    • Zarejestruj swoją firmę rachunkową
    Skorzystaj z usług
    • Znajdź partnera
    • Znajdź księgowego
    • Spotkaj się z doradcą
    • Usługi wdrożenia
    • Opinie klientów
    • Wsparcie
    • Aktualizacje
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Zaplanuj demo
  • Cennik
  • Pomoc

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Księgowość
  • Zapasy
  • PoS
  • Projekt
  • MRP
All apps
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
Wszystkie posty Osoby Odznaki
Tagi (Zobacz wszystko)
odoo accounting v14 pos v15
O tym forum
Pomoc

account.invoice.line

Zaprenumeruj

Otrzymaj powiadomienie o aktywności w tym poście

To pytanie dostało ostrzeżenie
account.moveaccount.move.line
2 Odpowiedzi
7964 Widoki
Awatar
Mohamed AlObaid

hi i really need your help i have a module in odoo 14 that inherit account.move and account.move.line what i am trying to do is to add new field in the invoice lines i did this successfully and the subtotal is calculated base on the new fields for example : subtotal = price_unit * quantity * date_deffrence date_deffrence is the new field and it is integer feld the problem is the sub total is not changeing in my code can you pleas tell me how can i acheve this thanks

0
Awatar
Odrzuć
Mohamed AlObaid
Autor

hi thanks man you code is working greatly but win i aply it i get error in the tax felds

einv_amount_tax = fields.Monetary(string="Amount tax", compute="_compute_amount_tax", help="")

@api.depends('tax_ids', 'discount', 'quantity', 'price_unit', 'einv_price_subtotal')
def _compute_amount_tax(self):
for r in self:
r.einv_amount_tax = sum(r.einv_price_subtotal * (tax.amount / 100) for tax in r.tax_ids)

this is my fields and my method
and it is give me THE SAME error

File "C:\Program Files (x86)\odoo14\server\odoo\addons\einv_sa\model\account_move.py", line 193, in _compute_subtotal
rec.einv_price_subtotal = rec.price_unit * rec.quantity * rec.date_difference
File "C:\Program Files (x86)\odoo14\server\odoo\fields.py", line 1028, in __get__
raise ValueError("Compute method failed to assign %s.%s" % (record, self.name))
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Program Files (x86)\odoo14\server\odoo\http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\Program Files (x86)\odoo14\server\odoo\http.py", line 316, in _handle_exception
raise exception.with_traceback(None) from new_cause
ValueError: Compute method failed to assign account.move.line(100,).date_difference

and this error shown if i chose a tax id in the tax feld in the line

Awatar
Mohamed AlObaid
Autor Najlepsza odpowiedź

Hi CorTex IT Solutions Ltd 

thanks for your answer

 this code is exactly what i wrote it but unfortunately it is not working


ok my code is like this :

class AccountMoveLine(models.Model):
_name = "account.move.line"
_inherit = "account.move.line"

einv_amount_discount = fields.Monetary(string="Amount discount", compute="_compute_amount_discount", store='True',
help="")
einv_amount_tax = fields.Monetary(string="Amount tax", compute="_compute_amount_tax", store='True', help="")

# price_sup_total
einv_price_subtotal = fields.Monetary(string='sub total', compute='_compute_price_total')
# price_to_tal
einv_price_total = fields.Monetary(string='total', compute='_price_to_tal')
dayes = fields.Char(string="Days", store=True)
date_s = fields.Date(string="Start D", store='True')
date_e = fields.Date(string="End D", store='True')
date_difference = fields.Integer(string="dayes", compute="_compute_dayes", default=1)
invoice_line_ids = fields.Many2one('account.move')

@api.depends('date_s', 'date_e', 'date_difference')
def _compute_dayes(self):
for r in self:
if r.date_s and r.date_e:
date_ss = datetime.strptime(str(r.date_s), '%Y-%m-%d').date()
date_ee = datetime.strptime(str(r.date_e), '%Y-%m-%d').date()
cek_hasil = (date_ee - date_ss).days
r.date_difference = (int(cek_hasil)) # / 100000
# cek_day = r.sub('[^0-9]', '', str(cek_hasil))

@api.depends('price_unit', 'quantity', 'date_difference', 'invoice_line_ids')
def _compute_price_total(self):
for line in self:
for res in line.invoice_line_ids:
line.einv_price_subtotal = line.price_unit * res.quantity * line.date_difference

@api.depends('discount', 'quantity', 'price_unit')
def _compute_amount_discount(self):
for r in self:
r.einv_amount_discount = r.quantity * r.price_unit * (r.discount / 100)

@api.depends('tax_ids', 'discount', 'quantity', 'price_unit', 'einv_price_subtotal')
def _compute_amount_tax(self):
for r in self:
r.einv_amount_tax = sum(r.einv_price_subtotal * (tax.amount / 100) for tax in r.tax_ids)

@api.depends('einv_amount_tax', 'einv_price_subtotal', 'invoice_line_ids')
def _price_to_tal(self):
for line in self:
for res in line.invoice_line_ids:
line.einv_price_total = line.einv_price_subtotal + line.einv_amount_tax


and after that i simple have a report print the invoice 




and it is get me this error


Odoo Server Error
Traceback (most recent call last):
  File "C:\Program Files (x86)\odoo14\server\odoo\api.py", line 793, in get
    return field_cache[record._ids[0]]
KeyError: 55

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\odoo14\server\odoo\fields.py", line 972, in __get__
    value = env.cache.get(record, self)
  File "C:\Program Files (x86)\odoo14\server\odoo\api.py", line 796, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'account.move.line(55,).einv_price_subtotal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\odoo14\server\odoo\api.py", line 793, in get
    return field_cache[record._ids[0]]
KeyError: 55

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\odoo14\server\odoo\fields.py", line 1025, in __get__
    value = env.cache.get(record, self)
  File "C:\Program Files (x86)\odoo14\server\odoo\api.py", line 796, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'account.move.line(55,).einv_price_subtotal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\qweb.py", line 331, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "", line 1, in template_einv_sa_inv_lines_222
  File "", line 62, in foreach_221
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_qweb.py", line 380, in _get_field
    content = converter.record_to_html(record, field_name, field_options)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_qweb_fields.py", line 484, in record_to_html
    return super(MonetaryConverter, self).record_to_html(record, field_name, options)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_qweb_fields.py", line 128, in record_to_html
    value = record[field_name]
  File "C:\Program Files (x86)\odoo14\server\odoo\models.py", line 5675, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "C:\Program Files (x86)\odoo14\server\odoo\fields.py", line 1028, in __get__
    raise ValueError("Compute method failed to assign %s.%s" % (record, self.name))
ValueError: Compute method failed to assign account.move.line(55,).einv_price_subtotal

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\web\controllers\main.py", line 2124, in report_download
    response = self.report_routes(reportname, docids=docids, converter=converter, context=context)
  File "C:\Program Files (x86)\odoo14\server\odoo\http.py", line 532, in response_wrap
    response = f(*args, **kw)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\web\controllers\main.py", line 2059, in report_routes
    pdf = report.with_context(context)._render_qweb_pdf(docids, data=data)[0]
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\account\models\ir_actions_report.py", line 50, in _render_qweb_pdf
    return super()._render_qweb_pdf(res_ids=res_ids, data=data)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_actions_report.py", line 805, in _render_qweb_pdf
    html = self_sudo.with_context(context)._render_qweb_html(res_ids, data=data)[0]
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_actions_report.py", line 846, in _render_qweb_html
    return self._render_template(self.report_name, data), 'html'
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_actions_report.py", line 582, in _render_template
    return view_obj._render_template(template, values)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_ui_view.py", line 1708, in _render_template
    return self.browse(self.get_view_id(template))._render(values, engine)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\website\models\ir_ui_view.py", line 420, in _render
    return super(View, self)._render(values, engine=engine, minimal_qcontext=minimal_qcontext)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\web_editor\models\ir_ui_view.py", line 28, in _render
    return super(IrUiView, self)._render(values=values, engine=engine, minimal_qcontext=minimal_qcontext)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_ui_view.py", line 1716, in _render
    return self.env[engine]._render(self.id, qcontext)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_qweb.py", line 55, in _render
    result = super(IrQWeb, self)._render(id_or_xml_id, values=values, **context)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\qweb.py", line 258, in _render
    self.compile(template, options)(self, body.append, values or {})
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\qweb.py", line 333, in _compiled_fn
    raise e
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\qweb.py", line 331, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "", line 1, in template_einv_sa_account_move_report_170
  File "", line 2, in body_call_content_168
  File "", line 3, in foreach_167
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\qweb.py", line 333, in _compiled_fn
    raise e
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\qweb.py", line 331, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "", line 1, in template_einv_sa_account_move_report_document_187
  File "", line 3, in body_call_content_185
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\qweb.py", line 338, in _compiled_fn
    raise QWebException("Error to render compiling AST", e, path, node and etree.tostring(node[0], encoding='unicode'), name)
odoo.addons.base.models.qweb.QWebException: Compute method failed to assign account.move.line(55,).einv_price_subtotal
Traceback (most recent call last):
  File "C:\Program Files (x86)\odoo14\server\odoo\api.py", line 793, in get
    return field_cache[record._ids[0]]
KeyError: 55

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\odoo14\server\odoo\fields.py", line 972, in __get__
    value = env.cache.get(record, self)
  File "C:\Program Files (x86)\odoo14\server\odoo\api.py", line 796, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'account.move.line(55,).einv_price_subtotal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\odoo14\server\odoo\api.py", line 793, in get
    return field_cache[record._ids[0]]
KeyError: 55

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\odoo14\server\odoo\fields.py", line 1025, in __get__
    value = env.cache.get(record, self)
  File "C:\Program Files (x86)\odoo14\server\odoo\api.py", line 796, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'account.move.line(55,).einv_price_subtotal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\qweb.py", line 331, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "", line 1, in template_einv_sa_inv_lines_222
  File "", line 62, in foreach_221
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_qweb.py", line 380, in _get_field
    content = converter.record_to_html(record, field_name, field_options)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_qweb_fields.py", line 484, in record_to_html
    return super(MonetaryConverter, self).record_to_html(record, field_name, options)
  File "C:\Program Files (x86)\odoo14\server\odoo\addons\base\models\ir_qweb_fields.py", line 128, in record_to_html
    value = record[field_name]
  File "C:\Program Files (x86)\odoo14\server\odoo\models.py", line 5675, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "C:\Program Files (x86)\odoo14\server\odoo\fields.py", line 1028, in __get__
    raise ValueError("Compute method failed to assign %s.%s" % (record, self.name))
ValueError: Compute method failed to assign account.move.line(55,).einv_price_subtotal

Error to render compiling AST
ValueError: Compute method failed to assign account.move.line(55,).einv_price_subtotal
Template: einv_sa.inv_lines
Path: /t/table/tbody/tr/td[7]/span
Node: 

so any help pleas





0
Awatar
Odrzuć
Waleed Mohsen (CorTex IT Solutions)

If the store equal to True then the code will run the first time when you install the module and then whenever there is a change in any of the three fields mentioned in the depends the compute method will be called.

Try to set the store=false and upgrade the module.

Waleed Mohsen (CorTex IT Solutions)

If you have a compute field in your model and you set store=True for the field, the field value will not get recomputed if proper depends is not given for the compute function.

Please post your code here

Waleed Mohsen (CorTex IT Solutions)

Replace the below line as you are set Store=True and its should be store=True. Also you are set store=True for not computed fields.

compute="_compute_amount_discount", store=True,help="")
einv_amount_tax = fields.Monetary(string="Amount tax", compute="_compute_amount_tax", store=True, help="")

dayes = fields.Char(string="Days")
date_s = fields.Date(string="Start D")
date_e = fields.Date(string="End D")

There below error is self explained:
Compute method failed to assign account.move.line(55,).einv_price_subtotal

There is no invoice_line_ids in account.move.line so your method should be

@api.depends('price_unit', 'quantity', 'date_difference',)
def _compute_price_total(self):
for line in self:
line.einv_price_subtotal = line.price_unit * line.quantity * line.date_difference

Mohamed AlObaid
Autor

Thanks man you are the best

Mohamed AlObaid
Autor

hi thanks man you code is working greatly but win i aply it i get error in the tax felds

einv_amount_tax = fields.Monetary(string="Amount tax", compute="_compute_amount_tax", help="")

@api.depends('tax_ids', 'discount', 'quantity', 'price_unit', 'einv_price_subtotal')
def _compute_amount_tax(self):
for r in self:
r.einv_amount_tax = sum(r.einv_price_subtotal * (tax.amount / 100) for tax in r.tax_ids)

this is my field and my method
and it is give me THE SAME error

File "C:\Program Files (x86)\odoo14\server\odoo\addons\einv_sa\model\account_move.py", line 193, in _compute_subtotal
rec.einv_price_subtotal = rec.price_unit * rec.quantity * rec.date_difference
File "C:\Program Files (x86)\odoo14\server\odoo\fields.py", line 1028, in __get__
raise ValueError("Compute method failed to assign %s.%s" % (record, self.name))
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Program Files (x86)\odoo14\server\odoo\http.py", line 640, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\Program Files (x86)\odoo14\server\odoo\http.py", line 316, in _handle_exception
raise exception.with_traceback(None) from new_cause
ValueError: Compute method failed to assign account.move.line(100,).date_difference

and this error shwon if i chose a tax id in the tax feld in the line

Waleed Mohsen (CorTex IT Solutions)

The issue is the below:
ValueError: Compute method failed to assign account.move.line(100,).date_difference

The date_difference computed method is not correct. try to use log or print the value to check if it's calculated correct value or not

Awatar
Waleed Mohsen (CorTex IT Solutions)
Najlepsza odpowiedź

You can define the subtotal as computed field and you can choose to store it in DB or not by adding attribute store=True.

Define subtotal field:

subtotal = fields.Float(string='SubTotal',compute='_compute_subtotal', store=True)

Then define computed method:

@api.depends('price_unit',' quantity',' date_deffrence')

def   _compute_subtotal(self)

    for line in self:

         line.subtotal = line.price_unit * line.quantity * line.date_deffrence


Note if the date_deffrence is zero the subtotal will be zero.

0
Awatar
Odrzuć
Podoba Ci się ta dyskusja? Dołącz do niej!

Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!

Zarejestruj się
Powiązane posty Odpowiedzi Widoki Czynność
[SOLVED] get data from mrp.production into account.move.line, but it won't show
account.move account.move.line mrp.production
Awatar
0
cze 24
4236
add my custum field in account.move.line view in odoo 16 enterprise
account.move tree_view account.move.line
Awatar
Awatar
Awatar
2
lis 23
4847
account.move.line with API Rozwiązane
api account.move account.move.line
Awatar
Awatar
Awatar
Awatar
3
sty 24
21717
Create "account.move" from code in odooV13.
account.move python3 account.move.line Odoo13.0
Awatar
Awatar
1
maj 25
10689
Can anyone give me an example PHP API call to search Account.Move
account.move
Awatar
Awatar
Awatar
Awatar
Awatar
4
lut 24
6351
Społeczność
  • Samouczki
  • Dokumentacja
  • Forum
Open Source
  • Pobierz
  • Github
  • Runbot
  • Tłumaczenia
Usługi
  • Hosting Odoo.sh
  • Wsparcie
  • Aktualizacja
  • Indywidualne rozwiązania
  • Edukacja
  • Znajdź księgowego
  • Znajdź partnera
  • Zostań partnerem
O nas
  • Nasza firma
  • Zasoby marki
  • Skontaktuj się z nami
  • Oferty pracy
  • Wydarzenia
  • Podcast
  • Blog
  • Klienci
  • Informacje prawne • Prywatność
  • Bezpieczeństwo Odoo
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo to pakiet aplikacji biznesowych typu open source, które zaspokoją wszystkie potrzeby Twojej firmy: CRM, eCommerce, księgowość, inwentaryzacja, punkt sprzedaży, zarządzanie projektami itp.

Unikalną wartością Odoo jest to, że jest jednocześnie bardzo łatwe w użyciu i w pełni zintegrowane.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now