From ebbc20544d00715bf620be2c92216f492af6d644 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Sun, 15 Sep 2024 14:27:17 +0300 Subject: [PATCH] Update project_invoice.py --- .../project_base/models/project_invoice.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/odex25_project/project_base/models/project_invoice.py b/odex25_project/project_base/models/project_invoice.py index b93e79323..91b3cef8f 100644 --- a/odex25_project/project_base/models/project_invoice.py +++ b/odex25_project/project_base/models/project_invoice.py @@ -52,7 +52,8 @@ class ProjectInvoice(models.Model): allowed_internal_user_ids = fields.Many2many('res.users', 'project_invoice_allowed_internal_users_rel', string="Allowed Internal Users", default=lambda self: self.env.user, domain=[('share', '=', False)]) allowed_portal_user_ids = fields.Many2many('res.users', 'project_invoice_allowed_portal_users_rel', string="Allowed Portal Users", domain=[('share', '=', True)]) - + + @api.depends('invoice_id','invoice_id.invoice_payments_widget','name') def _compute_indo_invoice_id(self): for record in self: @@ -279,11 +280,11 @@ class ProjectInvoiceLine(models.Model): project_invoice_id = fields.Many2one('project.invoice', string='Project Invoice', required=True, ondelete='cascade', index=True, copy=False) - product_id = fields.Many2one('product.product', string='Product') + product_id = fields.Many2one('product.product',digits='Product Unit of Measure', string='Product') product_uom_qty = fields.Float(string='Percentage', required=True, default=0.0) amount = fields.Monetary("Amount") product_uom = fields.Many2one('uom.uom', string='Unit of Measure', ) - price_unit = fields.Float('Unit Price', digits='Project Amount',store=True, compute="get_price_unit_value") + price_unit = fields.Float('Unit Price', digits='Project Amount') discount = fields.Float(string='Discount (%)', digits='Discount') price_subtotal = fields.Monetary(string='Subtotal', store=True) price_tax = fields.Float(string='Total Tax', compute="_compute_amount", store=True) @@ -297,10 +298,13 @@ class ProjectInvoiceLine(models.Model): name = fields.Char() account_id = fields.Many2one(comodel_name='account.account',) - @api.depends("project_invoice_id") + @api.onchange("project_invoice_id.project_invline_ids") def get_price_unit_value(self): for rec in self: rec.price_unit = rec.project_invoice_id.project_id.contract_value_untaxed + + + @api.onchange("price_unit") def get_project_invoice_id(self):