Skip to content

Commit

Permalink
[MIG] l10n_it_ricevute_bancarie: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyMasciI committed Jan 27, 2023
1 parent 12fc4f0 commit 56c8cb9
Show file tree
Hide file tree
Showing 21 changed files with 185 additions and 153 deletions.
2 changes: 1 addition & 1 deletion l10n_it_ricevute_bancarie/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{
"name": "ITA - Ricevute bancarie",
"version": "14.0.1.2.2",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"author": "Odoo Community Association (OCA)",
"category": "Localization/Italy",
Expand Down
4 changes: 1 addition & 3 deletions l10n_it_ricevute_bancarie/data/riba_sequence.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="1">
<odoo noupdate="1">

<record id="seq_riba_distinta" model="ir.sequence">
<field name="name">C/O Slip</field>
Expand All @@ -10,5 +9,4 @@
<field name="company_id" eval="False" />
</record>

</data>
</odoo>
15 changes: 6 additions & 9 deletions l10n_it_ricevute_bancarie/demo/riba_demo.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>

<!-- Payment Term -->
<record id="account_payment_term_riba" model="account.payment.term">
<field name="name">C/O 30 Days End of Month</field>
<field name="note">C/O 30 Days End of Month</field>
<field name="riba" eval="True" />
</record>

<record id="account_payment_term_line" model="account.payment.term.line">
<field name="value">balance</field>
<field name="option">day_following_month</field>
<field name="days">1</field>
<field ref="account_payment_term_riba" name="payment_id" />
<field
name="line_ids"
eval="[
Command.clear(),
Command.create({'value': 'balance', 'value_amount': 0.0, 'months': 1, 'days':0, 'end_month': True, 'days_after': 0})]"
/>
</record>

<!-- banks -->
Expand All @@ -36,5 +34,4 @@
<field name="bank_id" ref="res_bank_1" />
</record>

</data>
</odoo>
4 changes: 2 additions & 2 deletions l10n_it_ricevute_bancarie/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-30 21:25+0000\n"
"PO-Revision-Date: 2023-01-09 11:44+0000\n"
"PO-Revision-Date: 2023-01-03 12:47+0000\n"
"Last-Translator: Francesco Foresti <francesco.foresti@ooops404.com>\n"
"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n"
"Language: it\n"
Expand Down Expand Up @@ -644,7 +644,7 @@ msgstr "Nome file"
#: model:ir.model.fields,field_description:l10n_it_ricevute_bancarie.field_riba_distinta__message_follower_ids
#: model:ir.model.fields,field_description:l10n_it_ricevute_bancarie.field_riba_distinta_line__message_follower_ids
msgid "Followers"
msgstr "Follower"
msgstr ""

#. module: l10n_it_ricevute_bancarie
#: model:ir.model.fields,field_description:l10n_it_ricevute_bancarie.field_riba_distinta__message_channel_ids
Expand Down
16 changes: 0 additions & 16 deletions l10n_it_ricevute_bancarie/migrations/13.0.1.0.0/post-migration.py

This file was deleted.

13 changes: 0 additions & 13 deletions l10n_it_ricevute_bancarie/migrations/14.0.1.0.1/post-migration.py

This file was deleted.

42 changes: 29 additions & 13 deletions l10n_it_ricevute_bancarie/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _compute_is_unsolved(self):
"Is a past due invoice", compute="_compute_is_unsolved", store=True
)
is_riba_payment = fields.Boolean(
"Is C/O Payment", related="invoice_payment_term_id.riba", default=False
"Is C/O Payment", related="invoice_payment_term_id.riba"
)

riba_partner_bank_id = fields.Many2one(
Expand All @@ -88,7 +88,7 @@ def _compute_is_unsolved(self):
states={"draft": [("readonly", False)]},
)

@api.model
@api.model_create_multi
def create(self, vals):
invoice = super().create(vals)
if not invoice.riba_partner_bank_id:
Expand Down Expand Up @@ -117,7 +117,7 @@ def month_check(self, invoice_date_due, all_date_due):
:return: True if month of invoice_date_due is in a list of all_date_due
"""
for d in all_date_due:
if invoice_date_due[:7] == str(d.strftime("%Y-%m")):
if invoice_date_due.month == d.month and invoice_date_due.year == d.year:
return True
return False

Expand Down Expand Up @@ -152,9 +152,19 @@ def action_post(self):
pterm = self.env["account.payment.term"].browse(
self.invoice_payment_term_id.id
)
pterm_list = pterm.compute(value=1, date_ref=self.invoice_date)
pterm_list = pterm._compute_terms(
date_ref=self.invoice_date,
currency=self.currency_id,
company=self.company_id,
tax_amount=1,
tax_amount_currency=1,
untaxed_amount=0,
untaxed_amount_currency=0,
sign=1,
)

for pay_date in pterm_list:
if not self.month_check(pay_date[0], previous_date_due):
if not self.month_check(pay_date["date"], previous_date_due):
# ---- Get Line values for service product
service_prod = invoice.company_id.due_cost_service_id
account = service_prod.product_tmpl_id.get_product_accounts(
Expand All @@ -168,11 +178,10 @@ def action_post(self):
invoice.invoice_payment_term_id.riba_payment_cost
),
"due_cost_line": True,
"exclude_from_invoice_tab": False,
"name": _("{line_name} for {month}-{year}").format(
line_name=service_prod.name,
month=pay_date[0][5:7],
year=pay_date[0][:4],
month=pay_date["date"].month,
year=pay_date["date"].year,
),
"account_id": account.id,
"sequence": 9999,
Expand All @@ -183,20 +192,25 @@ def action_post(self):
line_vals.update({"tax_ids": [(4, tax.id)]})
invoice.write({"invoice_line_ids": [(0, 0, line_vals)]})
# ---- recompute invoice taxes
invoice._recompute_tax_lines()
invoice._sync_dynamic_lines(
container={"records": invoice, "self": invoice}
)
return super().action_post()

def button_draft(self):
# ---- Delete Collection Fees Line of invoice when set Back to Draft
# ---- line was added on new validate
super(AccountMove, self).button_draft()
res = super(AccountMove, self).button_draft()
for invoice in self:
due_cost_line_ids = invoice.get_due_cost_line_ids()
if due_cost_line_ids:
invoice.write(
{"invoice_line_ids": [(2, id, 0) for id in due_cost_line_ids]}
)
invoice._recompute_tax_lines()
invoice._sync_dynamic_lines(
container={"records": invoice, "self": invoice}
)
return res

def button_cancel(self):
for invoice in self:
Expand All @@ -219,7 +233,7 @@ def button_cancel(self):
riba=riba_line_ids.riba_line_id.distinta_id.name
)
)
super(AccountMove, self).button_cancel()
return super(AccountMove, self).button_cancel()

def copy(self, default=None):
self.ensure_one()
Expand All @@ -231,7 +245,9 @@ def copy(self, default=None):
invoice.write(
{"invoice_line_ids": [(2, id, 0) for id in due_cost_line_ids]}
)
invoice._recompute_tax_lines()
invoice._sync_dynamic_lines(
container={"records": invoice, "self": invoice}
)
return invoice

def get_due_cost_line_ids(self):
Expand Down
2 changes: 1 addition & 1 deletion l10n_it_ricevute_bancarie/models/bank_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get_move_lines_for_reconciliation(
ctx["bank_statement_line"] = self
generic_domain = (
self.env["account.move.line"]
.with_context(ctx)
.with_context(**ctx)
.domain_move_lines_for_reconciliation(str=str)
)

Expand Down
31 changes: 12 additions & 19 deletions l10n_it_ricevute_bancarie/models/riba.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def _compute_payment_ids(self):
("unsolved", "Past Due"),
("cancel", "Canceled"),
],
"State",
readonly=True,
default="draft",
)
Expand Down Expand Up @@ -116,7 +115,6 @@ def _compute_payment_ids(self):
)
type = fields.Selection(string="Type", related="config_id.type", readonly=True)
registration_date = fields.Date(
"Registration Date",
states={
"draft": [("readonly", False)],
"cancel": [("readonly", False)],
Expand All @@ -142,12 +140,12 @@ def unlink(self):
if riba_list.state not in ("draft", "cancel"):
raise UserError(
_(
"Slip %s is in state '%s'. You can only delete documents"
"Slip %(name)s is in state '%(state)s'. You can only delete documents"
" in state 'Draft' or 'Canceled'."
)
% (riba_list.name, riba_list.state)
% {"name": riba_list.name, "state": riba_list.state}
)
super(RibaList, self).unlink()
return super(RibaList, self).unlink()

def confirm(self):
for distinta in self:
Expand Down Expand Up @@ -251,13 +249,9 @@ def _compute_line_values(self):
),
)

amount = fields.Float(compute="_compute_line_values", string="Amount")
invoice_date = fields.Char(
compute="_compute_line_values", string="Invoice Date", size=256
)
invoice_number = fields.Char(
compute="_compute_line_values", string="Invoice Number", size=256
)
amount = fields.Float(compute="_compute_line_values")
invoice_date = fields.Char(compute="_compute_line_values", size=256)
invoice_number = fields.Char(compute="_compute_line_values", size=256)
cig = fields.Char(compute="_compute_cig_cup_values", string="CIG", size=256)
cup = fields.Char(compute="_compute_cig_cup_values", string="CUP", size=256)

Expand Down Expand Up @@ -334,7 +328,7 @@ def _compute_lines(self):
"riba.distinta", string="Slip", required=True, ondelete="cascade"
)
partner_id = fields.Many2one("res.partner", string="Customer", readonly=True)
due_date = fields.Date("Due Date", readonly=True)
due_date = fields.Date(readonly=True)
state = fields.Selection(
[
("draft", "Draft"),
Expand All @@ -344,7 +338,6 @@ def _compute_lines(self):
("unsolved", "Past Due"),
("cancel", "Canceled"),
],
"State",
readonly=True,
tracking=True,
)
Expand Down Expand Up @@ -404,7 +397,7 @@ def confirm(self):
[riba_move_line_name, riba_move_line.move_line_id.name]
).lstrip()
move_line = move_line_model.with_context(
{"check_move_validity": False}
check_move_validity=False
).create(
{
"name": (
Expand All @@ -421,7 +414,7 @@ def confirm(self):
)
to_be_reconciled |= move_line
to_be_reconciled |= riba_move_line.move_line_id
move_line_model.with_context({"check_move_validity": False}).create(
move_line_model.with_context(check_move_validity=False).create(
{
"name": "C/O %s-%s Ref. %s - %s"
% (
Expand Down Expand Up @@ -489,7 +482,7 @@ def riba_line_settlement(self):
)

move_line_credit = move_line_model.with_context(
{"check_move_validity": False}
check_move_validity=False
).create(
{
"name": move_ref,
Expand All @@ -502,7 +495,7 @@ def riba_line_settlement(self):
)

accr_acc = riba_line.distinta_id.config_id.accreditation_account_id
move_line_model.with_context({"check_move_validity": False}).create(
move_line_model.with_context(check_move_validity=False).create(
{
"name": move_ref,
"account_id": accr_acc.id,
Expand All @@ -525,7 +518,7 @@ class RibaListMoveLine(models.Model):
_description = "C/O Details"
_rec_name = "amount"

amount = fields.Float("Amount", digits="Account")
amount = fields.Float(digits="Account")
move_line_id = fields.Many2one("account.move.line", string="Credit Move Line")
riba_line_id = fields.Many2one(
"riba.distinta.line", string="Slip Line", ondelete="cascade"
Expand Down
2 changes: 0 additions & 2 deletions l10n_it_ricevute_bancarie/report/report.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data>

<record id="print_distinta_qweb" model="ir.actions.report">
<field name="name">Print Slip</field>
Expand All @@ -12,5 +11,4 @@
<field name="binding_type">report</field>
</record>

</data>
</odoo>
Loading

0 comments on commit 56c8cb9

Please sign in to comment.