fix accounting issues

This commit is contained in:
ronozoro 2024-09-28 14:36:37 -07:00
parent ca197ac16d
commit f326b5ead9
No known key found for this signature in database
GPG Key ID: 7C2BDED35C62C0F3
8 changed files with 79 additions and 19 deletions

View File

@ -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):
"""

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from . import controllers
from . import models
from . import models
from . import wizard

View File

@ -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,

View File

@ -60,7 +60,7 @@
</xpath>
<xpath expr="//div[hasclass('oe_button_box')]" position="inside">
<button class="oe_stat_button" name="open_confirmation" type="object" string="Budget Confirmation"/>
<button class="oe_stat_button" name="open_confirmation" type="object" string="Budget Confirmation" attrs="{'invisible': [('move_type', '!=', 'in_invoice')]}"/>
</xpath>
<button name="button_cancel" position="attributes">

View File

@ -0,0 +1 @@
from . import payment_register

View File

@ -0,0 +1,50 @@
from odoo import models,fields
class AccountPayment(models.Model):
_inherit = 'account.payment'
hr_request_pledge = fields.Boolean(string='Pledge', default=False)
class AccountPaymentRegister(models.TransientModel):
_inherit = 'account.payment.register'
def _create_payments(self):
self.ensure_one()
batches = self._get_batches()
edit_mode = self.can_edit_wizard and (len(batches[0]['lines']) == 1 or self.group_payment)
to_process = []
if edit_mode:
payment_vals = self._create_payment_vals_from_wizard()
to_process.append({
'create_vals': payment_vals,
'to_reconcile': batches[0]['lines'],
'batch': batches[0],
})
else:
# Don't group payments: Create one batch per move.
if not self.group_payment:
new_batches = []
for batch_result in batches:
for line in batch_result['lines']:
new_batches.append({
**batch_result,
'lines': line,
})
batches = new_batches
for batch_result in batches:
to_process.append({
'create_vals': self._create_payment_vals_from_batch(batch_result),
'to_reconcile': batch_result['lines'],
'batch': batch_result,
})
payments = self._init_payments(to_process, edit_mode=edit_mode)
process_final = [item for item in to_process if item['create_vals']['payment_type'] != 'outbound']
self._post_payments(process_final, edit_mode=edit_mode)
self._reconcile_payments(process_final, edit_mode=edit_mode)
for payment in payments:
if payment.payment_type == 'outbound':
payment.action_cancel()
payment.action_draft()
return payments

View File

@ -48,7 +48,7 @@ class AccountPayment(models.Model):
payment_state = self.state
res = super(AccountPayment, self).action_cancel()
for payment in self:
if self.payment_type == 'outbound':
if self.payment_type == 'outbound' and payment.state!='draft':
self._check_permission(f'odex25_account_payment_fix.group_{payment.state}')
if payment_state == 'draft':
payment.state = 'cancel'

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_account_payment_form_inherit_odex25_account_accountant" model="ir.ui.view">
<record id="view_account_payment_form_inherit_odex25_account_accountant_test" model="ir.ui.view">
<field name="name">account.payment.form.inherit.odex25_account_accountant</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_form"/>