From 4353c954127c82e70963889f44ef3195ee4cfc74 Mon Sep 17 00:00:00 2001 From: sonal Date: Sun, 2 Aug 2020 17:29:39 +0530 Subject: [PATCH] add new field on invoice --- tra_backend_Product/__manifest__.py | 5 +++-- tra_backend_Product/models/__init__.py | 1 + tra_backend_Product/models/account_move.py | 20 +++++++++++++++++++ .../views/account_move_view.xml | 19 ++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 tra_backend_Product/models/account_move.py create mode 100644 tra_backend_Product/views/account_move_view.xml diff --git a/tra_backend_Product/__manifest__.py b/tra_backend_Product/__manifest__.py index 91930e8..5e891f5 100644 --- a/tra_backend_Product/__manifest__.py +++ b/tra_backend_Product/__manifest__.py @@ -10,11 +10,12 @@ 'author': 'Masterkey', 'description': "", 'website': 'https://www.odoo.com/page/crm', - 'depends': ['product','base','sale_renting' + 'depends': ['product','base','sale_renting','account' ], 'data': [ 'views/product_views.xml', - 'views/partner_view.xml', + 'views/partner_view.xml', + 'views/account_move_view.xml' ], 'demo': [ diff --git a/tra_backend_Product/models/__init__.py b/tra_backend_Product/models/__init__.py index 8ad6e33..be02434 100644 --- a/tra_backend_Product/models/__init__.py +++ b/tra_backend_Product/models/__init__.py @@ -4,3 +4,4 @@ from . import product from . import partner +from . import account_move diff --git a/tra_backend_Product/models/account_move.py b/tra_backend_Product/models/account_move.py new file mode 100644 index 0000000..9caaa65 --- /dev/null +++ b/tra_backend_Product/models/account_move.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +from odoo import api, fields, models, _ +from odoo.exceptions import RedirectWarning, UserError, ValidationError, AccessError +from datetime import date + + +class AccountMove(models.Model): + _inherit = "account.move" + + + # ==== Business fields ==== + overdue_by = fields.Float(string='Overdue By', index=True, compute='calculate_overdue_date') + + + def calculate_overdue_date(self): + current_date = date.today() + overdue_date = self.invoice_due_date - current_date + self.overdue_by = overdue_date.days + diff --git a/tra_backend_Product/views/account_move_view.xml b/tra_backend_Product/views/account_move_view.xml new file mode 100644 index 0000000..62fb45d --- /dev/null +++ b/tra_backend_Product/views/account_move_view.xml @@ -0,0 +1,19 @@ + + + + + + + + account.invoice.tree + account.move + + + + + + + + + +