Skip to content

Commit

Permalink
Merge PR #1201 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by feketemihai
  • Loading branch information
OCA-git-bot committed Jan 16, 2025
2 parents 8364710 + f10c08a commit ef8c5b8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion l10n_ro_account_edi_ubl/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"views/cius_template.xml",
],
"license": "AGPL-3",
"version": "16.0.1.83.0",
"version": "16.0.1.83.1",
"author": "Terrabit," "NextERP Romania," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-romania",
"installable": True,
Expand Down
37 changes: 37 additions & 0 deletions l10n_ro_account_edi_ubl/migrations/16.0.1.83.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (C) 2025 NextERP Romania
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
import sys


def install(package):
try:
__import__(package)
except Exception:
import subprocess

subprocess.call([sys.executable, "-m", "pip", "install", package])


install("openupgradelib")

try:
from openupgradelib import openupgrade
except ImportError:
openupgrade = None


@openupgrade.migrate(use_env=True)
def migrate(env, version):

openupgrade.logged_query(
env.cr,
"""
UPDATE res_partner
SET l10n_ro_edi_ubl_no_send_cnp = True
FROM res_country
WHERE res_partner.country_id = res_country.id
AND res_country.code = 'RO'
AND res_partner.is_company = False
AND res_partner.parent_id IS NULL;
""",
)
14 changes: 13 additions & 1 deletion l10n_ro_account_edi_ubl/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2022 NextERP Romania
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models
from odoo import api, fields, models


class ResPartner(models.Model):
Expand All @@ -22,3 +22,15 @@ class ResPartner(models.Model):
"Romania - No send CNP UBL",
help="Check this if the partner should not receive UBL invoices on their CNP.",
)

@api.model_create_multi
def create(self, vals_list):
res = super().create(vals_list)
for record in res:
if (
record.country_id == self.env.ref("base.ro")
and not record.is_company
and not record.parent_id
):
record.l10n_ro_edi_ubl_no_send_cnp = True
return res

0 comments on commit ef8c5b8

Please sign in to comment.