Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

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

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

A new Due date invoices

Subscribe

Get notified when there's activity on this post

This question has been flagged
invoicedate
5968 Views
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
Discard
Enjoying the discussion? Don't just read, join in!

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

Sign up
Related Posts Replies Views Activity
Revenue - set a different accounting date to date of invoice Solved
accounting invoice date
Avatar
Avatar
Avatar
Avatar
3
Mar 25
7735
Invoice Date importing
invoice import date
Avatar
0
Sep 24
1833
Timesheet Date Range on Invoice
invoice date timesheet
Avatar
Avatar
1
Aug 24
2275
How to insert requested_date to invoice
invoice date delivery
Avatar
2
Oct 18
4421
Can i edit the date or the Tax Amount Once the Invoice is Created
invoice date edit
Avatar
Avatar
2
Jun 15
4380
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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