From f326b5ead96c297e34245877b7876fc9bf1ab76f Mon Sep 17 00:00:00 2001 From: ronozoro Date: Sat, 28 Sep 2024 14:36:37 -0700 Subject: [PATCH] fix accounting issues --- .../models/account_account.py | 23 ++++++++- .../exp_budget_check/__init__.py | 3 +- .../models/account_invoice.py | 15 +----- .../views/account_invoice_view.xml | 2 +- .../exp_budget_check/wizard/__init__.py | 1 + .../wizard/payment_register.py | 50 +++++++++++++++++++ .../models/account_payment.py | 2 +- .../views/account_payment_views.xml | 2 +- 8 files changed, 79 insertions(+), 19 deletions(-) create mode 100644 odex25_accounting/exp_budget_check/wizard/__init__.py create mode 100644 odex25_accounting/exp_budget_check/wizard/payment_register.py diff --git a/odex25_accounting/account_chart_of_accounts/models/account_account.py b/odex25_accounting/account_chart_of_accounts/models/account_account.py index 91a8484c8..93c98a6e6 100644 --- a/odex25_accounting/account_chart_of_accounts/models/account_account.py +++ b/odex25_accounting/account_chart_of_accounts/models/account_account.py @@ -69,14 +69,33 @@ class AccountAccount(models.Model): related='company_id.automticAccountsCodes', ) + def replace_type_with_internal_type(self,domain): + # Iterate over each condition and replace if necessary + new_domain = [] + for condition in domain: + if isinstance(condition, (list, tuple)) and condition[0] == 'type' and condition[1] == '!=' and condition[ + 2] == 'view': + # Replace ['type', '!=', 'view'] with ['internal_type', '!=', 'view'] + new_domain.append(('internal_type', '!=', 'view')) + else: + # Keep the condition as is + new_domain.append(condition) + return new_domain + @api.model def _name_search(self, name='', args=None, operator='ilike', limit=100, name_get_uid=None): if args is None: args = [] - domain = args + domain = args + domain = self.replace_type_with_internal_type(domain) if not self.env.context.get('show_view'): domain += [('internal_type', '!=', 'view')] return super(AccountAccount, self)._name_search(name, domain, operator ,limit ,name_get_uid) - + def _search(self, args, offset=0, limit=None, order=None, count=False, access_rights_uid=None): + domain = args + domain = self.replace_type_with_internal_type(domain) + if not self.env.context.get('show_view'): + args += [('internal_type', '!=', 'view')] + return super(AccountAccount, self)._search(domain, offset, limit, order, count, access_rights_uid) @api.depends('parent_id') def _get_level(self): """ diff --git a/odex25_accounting/exp_budget_check/__init__.py b/odex25_accounting/exp_budget_check/__init__.py index 511a0ca3a..a24914bff 100644 --- a/odex25_accounting/exp_budget_check/__init__.py +++ b/odex25_accounting/exp_budget_check/__init__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- from . import controllers -from . import models \ No newline at end of file +from . import models +from . import wizard \ No newline at end of file diff --git a/odex25_accounting/exp_budget_check/models/account_invoice.py b/odex25_accounting/exp_budget_check/models/account_invoice.py index a5acff887..5ca7b24db 100644 --- a/odex25_accounting/exp_budget_check/models/account_invoice.py +++ b/odex25_accounting/exp_budget_check/models/account_invoice.py @@ -78,12 +78,6 @@ class AccountMove(models.Model): self.write({ 'state': 'budget_approve' }) - other_confirms = self.env['budget.confirmation'].search( - [('invoice_id', '=', self.id), ('state', '=', 'cancel')], limit=1, - order='id desc') - if other_confirms: - other_confirms.state='draft' - return if self.purchase_id: confirm_budget = self.env['budget.confirmation'].search([('po_id', '=', self.purchase_id.id)], limit=1, order='id desc') @@ -154,11 +148,6 @@ class AccountMove(models.Model): confirmation_lines = [] self.hide_budget = True if not self.budget_check: - other_confirms = self.env['budget.confirmation'].search( - [('invoice_id', '=', self.id), ('state', '!=', 'cancel')], limit=1, - order='id desc') - if other_confirms: - return amount = 0 if self.purchase_id: confirm_budget = self.env['budget.confirmation'].search([('po_id', '=', self.purchase_id.id)], limit=1, @@ -186,10 +175,11 @@ class AccountMove(models.Model): confirmation_lines=[] else: remain = abs(budget_lines[0].remain) + tax_id = line.tax_ids[0].analytic if line.tax_ids else False amount = amount + (line.price_subtotal + line.price_tax) new_remain = remain - amount confirmation_lines.append((0, 0, { - 'amount': line.price_subtotal + line.price_tax, + 'amount': line.price_subtotal + (line.price_tax if tax_id else 0), 'analytic_account_id': line.analytic_account_id.id, 'description': line.product_id.name, 'budget_line_id': budget_lines[0].id, @@ -202,7 +192,6 @@ class AccountMove(models.Model): 'name': _('Vendor Bill :%s') % self.partner_id.name, 'date': self.invoice_date, 'beneficiary_id': self.partner_id.id, - # 'department_id': self.department_id.id, 'type': 'vendor.bill', 'ref': self.name, 'description': self.ref, diff --git a/odex25_accounting/exp_budget_check/views/account_invoice_view.xml b/odex25_accounting/exp_budget_check/views/account_invoice_view.xml index dcd45191f..823798436 100644 --- a/odex25_accounting/exp_budget_check/views/account_invoice_view.xml +++ b/odex25_accounting/exp_budget_check/views/account_invoice_view.xml @@ -60,7 +60,7 @@ -