Skip to content

Commit

Permalink
[FIX] functional migration and test
Browse files Browse the repository at this point in the history
  • Loading branch information
milleniumkid committed Feb 26, 2025
1 parent 3a3ca1b commit dcdb657
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 41 deletions.
1 change: 1 addition & 0 deletions account_check/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'views/account_chart_template_view.xml',
'security/ir.model.access.csv',
'security/account_check_security.xml',
'views/account_check_operation_view.xml',
],
'installable': True,
'auto_install': False,
Expand Down
10 changes: 5 additions & 5 deletions account_check/models/account_bank_statement_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
class AccountBankStatementLine(models.Model):
_inherit = "account.bank.statement.line"

def button_cancel_reconciliation(self):
def action_undo_reconciliation(self):
"""Delete operation of checks that are debited from statement"""
for st_line in self.filtered("move_name"):
if st_line.journal_entry_ids.filtered(
lambda x: x.payment_id.payment_reference == st_line.move_name
for st_line in self.filtered("payment_ref"):
if st_line.move_id.line_ids.filtered(
lambda x: x.payment_id.ref == st_line.payment_ref
):
check_operation = self.env["account.check.operation"].search(
[("origin", "=", "account.bank.statement.line,%s" % st_line.id)]
)
check_operation.check_id._del_operation(st_line)
return super(AccountBankStatementLine, self).button_cancel_reconciliation()
return super(AccountBankStatementLine, self).action_undo_reconciliation()

def process_reconciliation(
self, counterpart_aml_dicts=None, payment_aml_rec=None, new_aml_dicts=None
Expand Down
4 changes: 2 additions & 2 deletions account_check/models/account_chart_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def _create_bank_journals(self, company, acc_template_ref):
"name": "Cheques de Terceros",
"type": "cash",
"company_id": company.id,
"inbound_payment_method_ids": [(4, received_third_check.id, None)],
"outbound_payment_method_ids": [(4, delivered_third_check.id, None)],
"inbound_payment_method_line_ids": [(4, received_third_check.id, None)],
"outbound_payment_method_line_ids": [(4, delivered_third_check.id, None)],
}
)

Expand Down
31 changes: 22 additions & 9 deletions account_check/models/account_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def _add_operation(self, operation, origin, partner=None, date=False):
"* Operation Date: %s\n"
"* Last Operation Date: %s"
)
% (rec.id, rec.name, operation, date, rec.operation_ids[-1].date)
% (rec.id, rec.number, operation, date, rec.operation_ids[-1].date)
)
vals = {
"operation": operation,
Expand Down Expand Up @@ -457,10 +457,16 @@ def get_third_check_account(self):
# hacemos esa verificación
account = self.env["account.account"]
for rec in self:
credit_account = rec.journal_id.default_credit_account_id
debit_account = rec.journal_id.default_debit_account_id
inbound_methods = rec.journal_id["inbound_payment_method_ids"]
outbound_methods = rec.journal_id["outbound_payment_method_ids"]
credit_account = rec.journal_id.default_account_id.account_type in [
"liability_payable",
"asset_receivable",
]
debit_account = rec.journal_id.default_account_id.account_type in [
"liability_payable",
"asset_receivable",
]
inbound_methods = rec.journal_id["inbound_payment_method_line_ids"]
outbound_methods = rec.journal_id["outbound_payment_method_line_ids"]
# si hay cuenta en diario y son iguales, y si los metodos de pago
# y cobro son solamente uno, usamos el del diario, si no, usamos el
# de la compañía
Expand Down Expand Up @@ -615,7 +621,7 @@ def action_create_debit_note(self, operation, partner_type, partner, account):
vals["journal_id"] = journal.id or False
vals["date"] = action_date
move = self.env["account.move"].create(vals)
move.post()
move.action_post()
self._add_operation(operation, move, partner, date=action_date)

return True
Expand All @@ -626,9 +632,16 @@ def prepare_new_operation_move_values(
self.ensure_one()
ref = name
amount = self.amount
debit, credit, amount_currency, currency_id = self.env[
"account.move.line"
]._compute_amount_fields(amount, self.currency_id, self.company_currency_id)
if self.currency_id == self.company_currency_id:
debit = amount if amount > 0.0 else 0.0
credit = -amount if amount < 0.0 else 0.0
amount_currency = 0.0
currency_id = False
else:
debit = amount > 0.0 and self.company_currency_id.round(amount) or 0.0
credit = amount < 0.0 and self.company_currency_id.round(-amount) or 0.0
amount_currency = amount
currency_id = self.currency_id.id
if self.company_currency_id != self.currency_id:
currency_id = self.currency_id.id
else:
Expand Down
6 changes: 3 additions & 3 deletions account_check/models/account_checkbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ def _inverse_next_number(self):
rec.sequence_id.sudo().number_next_actual = rec.next_number

@api.model
def create(self, vals):
rec = super(AccountCheckbook, self).create(vals)
def create(self, vals_list):
rec = super(AccountCheckbook, self).create(vals_list)
if not rec.sequence_id:
rec._create_sequence(vals.get("next_number", 0))
rec._create_sequence(vals_list.get("next_number", 0))
return rec

def _create_sequence(self, next_number):
Expand Down
12 changes: 6 additions & 6 deletions account_check/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class AccountJournal(models.Model):
)

@api.model
def create(self, vals):
rec = super(AccountJournal, self).create(vals)
def create(self, vals_list):
rec = super(AccountJournal, self).create(vals_list)
issue_checks = self.env.ref("account_check.account_payment_method_issue_check")
if issue_checks in rec.outbound_payment_method_ids and not rec.checkbook_ids:
if issue_checks.id in rec.outbound_payment_method_line_ids.mapped('payment_method_id').ids and not rec.checkbook_ids:
rec._create_checkbook()
return rec

Expand Down Expand Up @@ -52,7 +52,7 @@ def _enable_issue_check_on_bank_journals(self):
bank_journal._create_checkbook()
bank_journal.write(
{
"outbound_payment_method_ids": [(4, issue_checks.id, None)],
"outbound_payment_method_line_ids": [(4, issue_checks.id, None)],
}
)

Expand Down Expand Up @@ -89,10 +89,10 @@ def get_journal_dashboard_datas(self):
num_checks_to_numerate=num_checks_to_numerate,
num_holding_third_checks=len(holding_checks),
show_third_checks=(
"received_third_check" in self.inbound_payment_method_ids.mapped("code")
"received_third_check" in self.inbound_payment_method_line_ids.mapped("code")
),
show_issue_checks=(
"issue_check" in self.outbound_payment_method_ids.mapped("code")
"issue_check" in self.outbound_payment_method_line_ids.mapped("code")
),
num_handed_issue_checks=len(handed_checks),
handed_amount=formatLang(
Expand Down
20 changes: 10 additions & 10 deletions account_check/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def cancel(self):
# de asientos ni cheques
if rec.state in ["confirmed", "posted"]:
rec.do_checks_operations(cancel=True)
res = super(AccountPayment, self).cancel()
res = super(AccountPayment, self).action_cancel()
return res

def create_check(self, check_type, operation, bank):
Expand All @@ -299,13 +299,13 @@ def create_check(self, check_type, operation, bank):
"type": self.check_type,
"journal_id": self.journal_id.id,
"amount": self.amount,
"payment_date": self.check_payment_date,
"date": self.check_payment_date,
"currency_id": self.currency_id.id,
}

check = self.env["account.check"].create(check_vals)
self.check_ids = [(4, check.id, False)]
check._add_operation(operation, self, self.partner_id, date=self.payment_date)
check._add_operation(operation, self, self.partner_id, date=self.date)
return check

def do_checks_operations(self, vals=None, cancel=False):
Expand Down Expand Up @@ -339,7 +339,7 @@ def do_checks_operations(self, vals=None, cancel=False):
# si el cheque es entregado en una transferencia tenemos tres
# opciones
# TODO we should make this method selectable for transfers
inbound_method = rec.destination_journal_id.inbound_payment_method_ids
inbound_method = rec.destination_journal_id.inbound_payment_method_line_ids
# si un solo inbound method y es received third check
# entonces consideramos que se esta moviendo el cheque de un diario
# al otro
Expand All @@ -360,10 +360,10 @@ def do_checks_operations(self, vals=None, cancel=False):
# get the account before changing the journal on the check
vals["account_id"] = rec.check_ids.get_third_check_account().id
rec.check_ids._add_operation(
"transfered", rec, False, date=rec.payment_date
"transfered", rec, False, date=rec.date
)
rec.check_ids._add_operation(
"holding", rec, False, date=rec.payment_date
"holding", rec, False, date=rec.date
)
rec.check_ids.write({"journal_id": rec.destination_journal_id.id})
vals["name"] = _("Transfer checks %s") % ", ".join(
Expand All @@ -376,7 +376,7 @@ def do_checks_operations(self, vals=None, cancel=False):
return None

_logger.info("Sold Check")
rec.check_ids._add_operation("sold", rec, False, date=rec.payment_date)
rec.check_ids._add_operation("sold", rec, False, date=rec.date)
vals["account_id"] = rec.check_ids.get_third_check_account().id
vals["name"] = _("Sell check %s") % ", ".join(
rec.check_ids.mapped("name")
Expand All @@ -390,7 +390,7 @@ def do_checks_operations(self, vals=None, cancel=False):

_logger.info("Deposited Check")
rec.check_ids._add_operation(
"deposited", rec, False, date=rec.payment_date
"deposited", rec, False, date=rec.date
)
vals["account_id"] = rec.check_ids.get_third_check_account().id
vals["name"] = _("Deposit checks %s") % ", ".join(
Expand All @@ -410,7 +410,7 @@ def do_checks_operations(self, vals=None, cancel=False):

_logger.info("Delivered Check")
rec.check_ids._add_operation(
"delivered", rec, rec.partner_id, date=rec.payment_date
"delivered", rec, rec.partner_id, date=rec.date
)
vals["account_id"] = rec.check_ids.get_third_check_account().id
vals["name"] = _("Deliver checks %s") % ", ".join(
Expand Down Expand Up @@ -497,7 +497,7 @@ def post(self):
_("Please be sure that check number or name is filled!")
)

res = super(AccountPayment, self).post()
res = super(AccountPayment, self).action_post()
return res

def _get_liquidity_move_line_vals(self, amount):
Expand Down
46 changes: 46 additions & 0 deletions account_check/views/account_check_operation_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="view_account_check_operation_tree" model="ir.ui.view">
<field name="name">account.check.operation.tree</field>
<field name="model">account.check.operation</field>
<field name="arch" type="xml">
<tree string="Çek Operasyonları">
<field name="operation"/>
</tree>
</field>
</record>

<record id="view_account_checkbook_form" model="ir.ui.view">
<field name="name">account.check.operation.form</field>
<field name="model">account.check.operation</field>
<field name="arch" type="xml">
<form string="Çek Operasyonları">
<sheet>
<group>
<field name="operation"/>
<field name="date"/>
<field name="check_id"/>
<field name="origin_name"/>
<field name="origin"/>
<field name="partner_id"/>
<field name="notes"/>
</group>
</sheet>
</form>
</field>
</record>

<record model="ir.actions.act_window" id="action_check_operation">
<field name="name">Çek Operasyonları</field>
<field name="res_model">account.check.operation</field>
<field name="view_mode">tree,form</field>
</record>

<menuitem
action="action_check_operation"
id="menu_check_operation"
sequence="30"
parent="menu_account_check_root"/>

</odoo>
10 changes: 6 additions & 4 deletions account_check/views/account_check_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@
</field>
</record>

<menuitem id="menu_account_check_root" name="Çek Yönetimi" parent="account.menu_finance" sequence="20"/>

<!-- Third Check Menu -->
<record model="ir.actions.act_window" id="action_third_check">
<field name="name">Third Checks</field>
Expand All @@ -211,11 +213,11 @@
</record>

<!--TODO: Enable This-->
<!-- <menuitem
<menuitem
action="action_third_check"
id="menu_third_check"
sequence="40"
parent="account_payment_fix.menu_finance_check_and_promissory_note"/> -->
parent="menu_account_check_root"/>

<!-- Issued Check Menu -->
<record model="ir.actions.act_window" id="action_issue_check">
Expand All @@ -226,11 +228,11 @@
<field name="context">{'default_type':'issue_check'}</field>
</record>
<!--TODO: Enable This-->
<!-- <menuitem
<menuitem
action="action_issue_check"
id="menu_issue_check"
sequence="50"
parent="account_payment_fix.menu_finance_check_and_promissory_note"/> -->
parent="menu_account_check_root"/>

<!-- Deposit Promissory Note Menu -->
<!-- <record model="ir.actions.act_window" id="action_deposit_promissory_note"> -->
Expand Down
4 changes: 2 additions & 2 deletions account_check/views/account_payment_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

<!-- Checks search view -->
<!-- TODO: Enable this -->
<!-- <record id="view_account_payment_search" model="ir.ui.view">
<record id="view_account_payment_search" model="ir.ui.view">
<field name="name">account.payment.check.search</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_search"/>
Expand All @@ -106,6 +106,6 @@
<filter string="Checks To Print and Numerate" domain="[('payment_method_id.code', '=', 'issue_check'), ('state','=','draft'), ('check_number', '=', False)]" name="checks_to_numerate"/>
</xpath>
</field>
</record> -->
</record>

</odoo>

0 comments on commit dcdb657

Please sign in to comment.