Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

How to make Analytic Account field as a required field?

Odoberať

Get notified when there's activity on this post

This question has been flagged
accountingodoov12
3 Replies
5762 Zobrazenia
Avatar
Sameer Ahmad

According to my requirement i need the Analytic Account field as mandatory in invoice line items and also journal entry line items. I have inherited and defined both of them as required=True.

Now when i validate a invoice the default odoo behavior saves some items in account_move_line table and as i defined the field analytic_account_id as required, when it tries to save or insert the data, it is throwing me a not null constraint error.

As a workaround i have removed the required=True in journal entry screen and i override the create and write methods to check for the same, below is my code

@api.model
def create(self, vals):
res = super(AccountMoveInherited, self).create(vals=vals)
lines = vals.get('line_ids')
if lines:
for line in lines:
values = line[2]
if values.get('analytic_account_id'):
continue
if not
values.get('analytic_account_id'):
raise UserError(_("Some Journal Entry items are missing "
"Analytic Account field, Please add them and try again."
))
return res

@api.multi
def write(self, vals):
res = super(AccountMoveInherited, self).write(vals=vals)
lines = vals.get('line_ids')
if lines:
for line in lines:
values = line[2]
if values.get('analytic_account_id'):
continue
if not
values.get('analytic_account_id'):
raise UserError(_("Journal Entry item(s) are missing "
"Analytic Account field, Please add them and try again."
))
return res

It works just fine but now when i try to validate an invoice, it is throwing me this error. I have wasted my 4 hours of time figuring this and implementing it and now i'm right at where i started.

Can anyone tell me a good approach to achieve my required functionality as i'm out of ideas and don't know how can i achieve the functionality anymore

0
Avatar
Zrušiť
Avatar
Sameer Ahmad
Autor Best Answer

I have noticed that when data is entered into invoice line items, the tax and ar/ap account data is being fed and stored in the account_move_line table and since tax is being  aggregated and stored as a single entry for all the invoice line items of a particular invoice, the analytic account wasn't being passed and stored into the table and since we made analytic_account_id as a required field, it was throwing an error. So as a temporary workaround i have hardcoded to add the analytic account of id 1 to all the items that are getting stored in account_move_line when an invoice is validated.

0
Avatar
Zrušiť
Avatar
Ahmed Salah
Best Answer

Hello,

you have to decide where exactly you need to check for analytic account. (create, edit, validate)

check before applying the validate

--> if in validate then you can just inherit the method which create the entry data.

I hope this is helpful for you


-1
Avatar
Zrušiť
Sameer Ahmad
Autor

I'm sorry but i'm afraid you didn't get my question correctly

Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Registrácia
Related Posts Replies Zobrazenia Aktivita
How to modify Balance Sheet report?
accounting reports odoov12
Avatar
Avatar
1
mar 19
8167
¿Cómo llamar a Jetblue Airlines en Mexico?
accounting
Avatar
0
nov 25
2
Rápida~@GUÍA\\¿Cómo hablar directamente con Air France?
accounting
Avatar
0
nov 25
2
Guía~Básica¿Cómo hablo con una persona en vivo en Delta?
accounting
Avatar
0
nov 25
3
[7191]¿Cómo llamar a Latam Bogotá desde celular?
accounting
Avatar
0
nov 25
38
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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