Overslaan naar inhoud
Odoo Menu
  • Aanmelden
  • Probeer het gratis
  • Apps
    Financiën
    • Boekhouding
    • Facturatie
    • Onkosten
    • Spreadsheet (BI)
    • Documenten
    • Ondertekenen
    Verkoop
    • CRM
    • Verkoop
    • Kassasysteem winkel
    • Kassasysteem Restaurant
    • Abonnementen
    • Verhuur
    Websites
    • Websitebouwer
    • E-commerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Bevoorradingsketen
    • Voorraad
    • Productie
    • PLM
    • Inkoop
    • Onderhoud
    • Kwaliteit
    Personeelsbeheer
    • Werknemers
    • Werving & Selectie
    • Verlof
    • Evaluaties
    • Aanbevelingen
    • Wagenpark
    Marketing
    • Social media Marketing
    • E-mailmarketing
    • SMS Marketing
    • Evenementen
    • Marketingautomatisering
    • Enquêtes
    Diensten
    • Project
    • Urenstaten
    • Buitendienst
    • Helpdesk
    • Planning
    • Afspraken
    Productiviteit
    • Chat
    • Goedkeuringen
    • IoT
    • VoIP
    • Kennis
    • WhatsApp
    Apps van derden Odoo Studio Odoo Cloud Platform
  • Bedrijfstakken
    Detailhandel
    • Boekhandel
    • kledingwinkel
    • Meubelzaak
    • Supermarkt
    • Bouwmarkt
    • Speelgoedwinkel
    Food & Hospitality
    • Bar en Pub
    • Restaurant
    • Fastfood
    • Gastenverblijf
    • Drankenhandelaar
    • Hotel
    Vastgoed
    • Makelaarskantoor
    • Architectenbureau
    • Bouw
    • Vastgoedbeheer
    • Tuinieren
    • Vereniging van eigenaren
    Consulting
    • Accountantskantoor
    • Odoo Partner
    • Marketingbureau
    • Advocatenkantoor
    • Talentenwerving
    • Audit & Certificering
    Productie
    • Textiel
    • Metaal
    • Meubels
    • Eten
    • Brewery
    • Relatiegeschenken
    Gezondheid & Fitness
    • Sportclub
    • Opticien
    • Fitnesscentrum
    • Wellness-medewerkers
    • Apotheek
    • Kapper
    Trades
    • Klusjesman
    • IT-hardware & support
    • Zonne-energiesystemen
    • Schoenmaker
    • Schoonmaakdiensten
    • HVAC-diensten
    Andere
    • Non-profitorganisatie
    • Milieuagentschap
    • Verhuur van Billboards
    • Fotograaf
    • Fietsleasing
    • Softwareverkoper
    Browse all Industries
  • Community
    Leren
    • Tutorials
    • Documentatie
    • Certificeringen
    • Training
    • Blog
    • Podcast
    Versterk het onderwijs
    • Onderwijs- programma
    • Scale Up! Business Game
    • Bezoek Odoo
    Download de Software
    • Downloaden
    • Vergelijk edities
    • Releases
    Werk samen
    • Github
    • Forum
    • Evenementen
    • Vertalingen
    • Word een Partner
    • Services for Partners
    • Registreer je accountantskantoor
    Diensten
    • Vind een partner
    • Vind een boekhouder
    • Een adviseur ontmoeten
    • Implementatiediensten
    • Klantreferenties
    • Ondersteuning
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Vraag een demo aan
  • Prijzen
  • Help

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

  • CRM
  • e-Commerce
  • Boekhouding
  • Voorraad
  • PoS
  • Project
  • MRP
All apps
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Alle posts Personen Badges
Labels (Bekijk alle)
odoo accounting v14 pos v15
Over dit forum
Help

How to compare date in domain from model?

Inschrijven

Ontvang een bericht wanneer er activiteit is op deze post

Deze vraag is gerapporteerd
invoiceoverdue_paymentodoo12
3 Antwoorden
12770 Weergaven
Avatar
thanhps

Hi,

I would like to display list of overdue invoices inside a tab (notebook/page) but it didn't work. 

The problem is the domain statement cannot calculate today value.

I moved the domain to view but it did not work also.

Please help me to resolve this issue. Thank you!

Here is my code

_inherit = 'res.partner'

overdue_invoice_ids = fields.One2many('account.invoice', 'partner_id', 'Overdue Invoices', readonly=True,
domain=[('state', 'in', ['open']), ('type', 'in', ['out_invoice']),
('date_due', '<', fields.Date.context_today)])
<field name="overdue_invoice_ids" nolabel="1">
<tree string="Invoice">
<field name="date_invoice"/>
<field name="number"/>
<field name="commercial_partner_id" invisible="1"/>
<field name="reference" invisible="1"/>
<field name="name" invisible="1"/>
<field name="date_due"/>
<field name="origin"/>
<field name="amount_untaxed" string="Tax Excluded" sum="Total"/>
<field name="amount_tax" sum="Total"/>
<field name="amount_total_signed" string="Total" sum="Total"/>
<field name="residual_signed" string="Amount Due" sum="Amount Due"/>
<field name="currency_id" invisible="1"/>
<field name="company_currency_id" invisible="1"/>
<field name="state"/>
<field name="type" invisible="context.get('type',True)"/>
</tree>
</field>
0
Avatar
Annuleer
Avatar
thanhps
Auteur Beste antwoord

I tried to resolve it by myself and luckily it works.

Here is my solution in model, with nothing change in view:

_inherit = 'res.partner'

@api.model
def _get_overdue_invoices(self):
today = fields.Date.context_today(self).strftime('%Y-%m-%d')
self.overdue_invoice_ids = self.env['account.invoice'].search(
[['state', '=', 'open'], ['type', '=', 'out_invoice'], ['date_due', '<', today]])

overdue_invoice_ids = fields.One2many('account.invoice', 'partner_id', 'Overdue Invoices',
compute='_get_overdue_invoices')

Thanks all for your help!


0
Avatar
Annuleer
Avatar
Jainesh Shah(Aktiv Software)
Beste antwoord

Hello @ThanhPs,

You can use this,

domain=[('state', 'in', ['open']), ('type', 'in', ['out_invoice']),('date_due', '<', context_today().strftime('%Y-%m-%d'))]

Regards,




Email: odoo@aktivsoftware.com

Skype: kalpeshmaheshwari

   

0
Avatar
Annuleer
thanhps
Auteur

@Aktiv software,

Thank you for your quick response! I already tried it but it seems valid in view only.

I am trying to add these domain in a model then it showed an error.

NameError: name 'context_today' is not defined

I also tried with ('date_due', '<', fields.Date.context_today) but it showed a SQL error:

ERROR: invalid input syntax for type date: "<function Date.context_today at 0x00000228D18407B8>"

LINE 1: ...invoice'))) AND ("account_invoice"."date_due" < '<function...

Avatar
faOtools
Beste antwoord

context_today is a method, you should add '()'. Otherwise you compare string to built-in method. So:

('date_due', '<', fields.Date.context_today())

UPDATE:
yes, context_today requires a record to check timezone. Hence, it might be used only 
in methods where you have self (recordset). In domain you can do it through lambda, like lamda self: self.env.user
(not sure about syntax here)

However, I guess it is better to use  today() instead of context_today, which doesn't require timezone.
I guess, timezone is not a big deal in your case:
('date_due', '<', fields.Date.today())

0
Avatar
Annuleer
thanhps
Auteur

@Odoo Tools

I tried it and still got an error, because I don't have something like 'self' as an argument:

This below is the error message:

('date_due', '<', fields.Date.context_today())])

TypeError: context_today() missing 1 required positional argument: 'record'

faOtools

Have a look at the answer update

thanhps
Auteur

Thank you so much for your help!

However, I prefer to use date with timezone in my case.

I updated my answer, take a look at it, pls.

Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!

Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!

Aanmelden
Gerelateerde posts Antwoorden Weergaven Activiteit
Open an invoice using XMLRPC
invoice odoo12
Avatar
Avatar
2
mei 20
5793
How to modify validated invoice?
invoice odoo12
Avatar
Avatar
Avatar
2
nov. 18
4964
How to control auto post for journal entry comes from invoices in Odoo12?
invoice journal_entry odoo12
Avatar
0
jan. 22
4201
Odoo12: TypeError: post() got an unexpected keyword argument 'invoice' Opgelost
invoice typeerror odoo12
Avatar
Avatar
3
feb. 20
17319
[v12] propagate custom field from invoice to invoice report
invoice invoicereport odoo12
Avatar
Avatar
3
dec. 19
5447
Community
  • Tutorials
  • Documentatie
  • Forum
Open Source
  • Downloaden
  • Github
  • Runbot
  • Vertalingen
Diensten
  • Odoo.sh Hosting
  • Ondersteuning
  • Upgrade
  • Gepersonaliseerde ontwikkelingen
  • Onderwijs
  • Vind een boekhouder
  • Vind een partner
  • Word een Partner
Over ons
  • Ons bedrijf
  • Merkelementen
  • Neem contact met ons op
  • Vacatures
  • Evenementen
  • Podcast
  • Blog
  • Klanten
  • Juridisch • Privacy
  • Beveiliging
الْعَرَبيّة 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 is een suite van open source zakelijke apps die aan al je bedrijfsbehoeften voldoet: CRM, E-commerce, boekhouding, inventaris, kassasysteem, projectbeheer, enz.

Odoo's unieke waardepropositie is om tegelijkertijd zeer gebruiksvriendelijk en volledig geïntegreerd te zijn.

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