Skip to Content
Odoo Menu
  • Prijavi
  • Try it free
  • Aplikacije
    Finance
    • Knjigovodstvo
    • Obračun
    • Stroški
    • Spreadsheet (BI)
    • Dokumenti
    • Podpisovanje
    Prodaja
    • CRM
    • Prodaja
    • POS Shop
    • POS Restaurant
    • Naročnine
    • Najem
    Spletne strani
    • Website Builder
    • Spletna trgovina
    • Blog
    • Forum
    • Pogovor v živo
    • eUčenje
    Dobavna veriga
    • Zaloga
    • Proizvodnja
    • PLM
    • Nabava
    • Vzdrževanje
    • Kakovost
    Kadri
    • Kadri
    • Kadrovanje
    • Odsotnost
    • Ocenjevanja
    • Priporočila
    • Vozni park
    Marketing
    • Družbeno Trženje
    • Email Marketing
    • SMS Marketing
    • Dogodki
    • Avtomatizacija trženja
    • Ankete
    Storitve
    • Projekt
    • Časovnice
    • Storitve na terenu
    • Služba za pomoč
    • Načrtovanje
    • Termini
    Produktivnost
    • Razprave
    • Odobritve
    • IoT
    • Voip
    • Znanje
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industrije
    Trgovina na drobno
    • Book Store
    • Trgovina z oblačili
    • Trgovina s pohištvom
    • Grocery Store
    • Trgovina s strojno opremo računalnikov
    • Trgovina z igračami
    Food & Hospitality
    • Bar and Pub
    • Restavracija
    • Hitra hrana
    • Guest House
    • Beverage Distributor
    • Hotel
    Nepremičnine
    • Real Estate Agency
    • Arhitekturno podjetje
    • Gradbeništvo
    • Estate Management
    • Vrtnarjenje
    • Združenje lastnikov nepremičnin
    Svetovanje
    • Računovodsko podjetje
    • Odoo Partner
    • Marketinška agencija
    • Law firm
    • Pridobivanje talentov
    • Audit & Certification
    Proizvodnja
    • Tekstil
    • Metal
    • Pohištvo
    • Hrana
    • Brewery
    • Poslovna darila
    Health & Fitness
    • Športni klub
    • Trgovina z očali
    • Fitnes center
    • Wellness Practitioners
    • Lekarna
    • Frizerski salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Sistemi sončne energije
    • Izdelovalec čevljev
    • Čistilne storitve
    • HVAC Services
    Ostali
    • Neprofitna organizacija
    • Agencija za okolje
    • Najem oglasnih panojev
    • Fotografija
    • Najem koles
    • Prodajalec programske opreme
    Browse all Industries
  • Skupnost
    Learn
    • Tutorials
    • Dokumentacija
    • Certifikati
    • Šolanje
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Prenesi
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Dogodki
    • Prevodi
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Sklici kupca
    • Podpora
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Določanje cen
  • Pomoč

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

  • CRM
  • e-Commerce
  • Knjigovodstvo
  • Zaloga
  • PoS
  • Projekt
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Ključne besede (View all)
odoo accounting v14 pos v15
About this forum
Pomoč

A new Due date invoices

Naroči se

Get notified when there's activity on this post

This question has been flagged
invoicedate
5997 Prikazi
Avatar
Quentin

I would like to modify the source code of a module to allow the calculation of a "due date invoices", the topic is to calculate it from the last day of a month.

I modified a file already modified and there is an associated view.xml but I don't know how I can modify this view.

I saved the former code in comment.

my account.py :

from openerp.osv import osv, fields

def compute(self, cr, uid, id, value, context=None):
    date_ref = datetime.now().strftime('%Y-%m-%d')
    if date_ref.month in (1,3,5,7,8,10,12):
        date_ref.day = 31
    elif date_ref.month in (4,6,9,11):
        date_ref.day = 30
    elif date_ref.month == 2:
        if date_ref.year % 400 == 0:
            date_ref.day = 29
        else :
            date_ref.day = 28
    date_ref = str(date_ref.year) + '-' + str(date_ref.month) + '-' + str(date_ref.day)
    pt = self.browse(cr, uid, id, context=context)
    amount = value
    result = []
    obj_precision = self.pool.get('decimal.precision')
    prec = obj_precision.precision_get(cr, uid, 'Account')
    for line in pt.line_ids:
        if line.value == 'fixed':
            amt = round(line.value_amount, prec)
        elif line.value == 'procent':
            amt = round(value * line.value_amount, prec)
        elif line.value == 'balance':
            amt = round(amount, prec)
        if amt:
            next_date = (datetime.strptime(date_ref, '%Y-%m-%d') + relativedelta(days=line.days))
            if line.days2 < 0:
                next_first_date = next_date + relativedelta(day=1) #Getting 1st of required month
                next_date = next_first_date + relativedelta(days=line.days2)
            if line.days2 > 0:
                next_date += relativedelta(day=line.days2)
            result.append( (next_date.strftime('%Y-%m-%d'), amt) )
            amount -= amt

    amount = reduce(lambda x,y: x+y[1], result, 0.0)
    dist = round(value-amount, prec)
    if dist:
        result.append( (time.strftime('%Y-%m-%d'), dist) )
    return result
#class account_payment_term_line(osv.osv):
#    _inherit = 'account.payment.term.line'
#    _name = 'account.payment.term.line'
#   _columns = {
#       'months': fields.integer('Months', required=True, help="Month, set 0 for the last day of the current month. This adds complete months to the calculation."),
#   }
#    _defaults = {
#        'months': 0,
#   }
#account_payment_term_line()

my monthly_payment_term_view.xml :

<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>

        <record id="monthly_payment_term_view" model="ir.ui.view">
            <field name="name">account.view_payment_term_line_form</field>
            <field name="inherit_id" ref="account.view_payment_term_line_form"/>
            <field name="model">account.payment.term.line</field>
            <field name="arch" type="xml">
                <xpath expr="//field[@name='days']" position="before">
                    <field name="months"/>
                </xpath>
            </field>
        </record>

    </data>
</openerp>

Thanks

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

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

Prijavi
Related Posts Odgovori Prikazi Aktivnost
Revenue - set a different accounting date to date of invoice Solved
accounting invoice date
Avatar
Avatar
Avatar
Avatar
3
mar. 25
7758
Invoice Date importing
invoice import date
Avatar
0
sep. 24
1854
Timesheet Date Range on Invoice
invoice date timesheet
Avatar
Avatar
1
avg. 24
2285
How to insert requested_date to invoice
invoice date delivery
Avatar
2
okt. 18
4433
Can i edit the date or the Tax Amount Once the Invoice is Created
invoice date edit
Avatar
Avatar
2
jun. 15
4397
Community
  • Tutorials
  • Dokumentacija
  • Forum
Open Source
  • Prenesi
  • Github
  • Runbot
  • Prevodi
Services
  • Odoo.sh Hosting
  • Podpora
  • Nadgradnja
  • Custom Developments
  • Izobraževanje
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Sredstva blagovne znamke
  • Kontakt
  • Zaposlitve
  • Dogodki
  • Podcast
  • Blog
  • Stranke
  • Pravno • Zasebnost
  • Varnost
الْعَرَبيّة 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 a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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