Skip to content

Commit

Permalink
Merge pull request #126 from dhongu/15.0-edi-check
Browse files Browse the repository at this point in the history
[15.0][UPD]edi check: fix country restrictions, add label length
  • Loading branch information
danila12 authored Jan 13, 2024
2 parents eaa3652 + 3afb3f0 commit ee02c8f
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 30 deletions.
3 changes: 2 additions & 1 deletion l10n_ro_edi_check/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Romania - EDI data check and queue
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2670c0de37d5788be945fc1e758bacefbe751da939ce0d106cf680fb5013779d
!! source digest: sha256:567d8a867738841397769cb264a077e2abb0851f1e7478afe27edb36653d65eb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -25,6 +25,7 @@ Romania - EDI data check and queue
- Verificare date pentru trimitere ANAF la validarea facturii
- Implementare cu coada job-uri
- Dezactivare recalculare pret unitar la facuri furnizor cu ID eFactura
- Camp nr. caractere descriere in linie factura

**Table of contents**

Expand Down
6 changes: 2 additions & 4 deletions l10n_ro_edi_check/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Romania - EDI data check and queue",
"license": "AGPL-3",
"version": "15.0.0.0.2",
"version": "15.0.0.0.3",
"author": "Terrabit," "Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-romania",
"category": "Tools",
Expand All @@ -12,8 +12,6 @@
"queue_job",
"queue_job_cron_jobrunner",
],
"data": [
"data/cron.xml",
],
"data": ["data/cron.xml", "views/account_move.xml"],
"installable": True,
}
89 changes: 89 additions & 0 deletions l10n_ro_edi_check/i18n/ro.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_ro_edi_check
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-13 05:33+0000\n"
"PO-Revision-Date: 2024-01-13 05:33+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: l10n_ro_edi_check
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_move_line__l10n_ro_label_length
msgid "Desc. length"
msgstr "Ln"

#. module: l10n_ro_edi_check
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_edi_document__display_name
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_edi_format__display_name
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_move__display_name
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_move_line__display_name
msgid "Display Name"
msgstr "Nume afișat"

#. module: l10n_ro_edi_check
#: model:ir.model,name:l10n_ro_edi_check.model_account_edi_format
msgid "EDI format"
msgstr "Format EDI"

#. module: l10n_ro_edi_check
#: model:ir.model,name:l10n_ro_edi_check.model_account_edi_document
msgid "Electronic Document for an account.move"
msgstr "Document electronic pentru account.move"

#. module: l10n_ro_edi_check
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_edi_document__id
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_edi_format__id
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_move__id
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_move_line__id
msgid "ID"
msgstr ""

#. module: l10n_ro_edi_check
#: model:ir.model,name:l10n_ro_edi_check.model_account_move
msgid "Journal Entry"
msgstr "Notă contabilă"

#. module: l10n_ro_edi_check
#: model:ir.model,name:l10n_ro_edi_check.model_account_move_line
msgid "Journal Item"
msgstr "Element jurnal"

#. module: l10n_ro_edi_check
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_edi_document____last_update
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_edi_format____last_update
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_move____last_update
#: model:ir.model.fields,field_description:l10n_ro_edi_check.field_account_move_line____last_update
msgid "Last Modified on"
msgstr "Ultima modificare la"

#. module: l10n_ro_edi_check
#: code:addons/l10n_ro_edi_check/models/account_move.py:0
#, python-format
msgid "Partenerul %s nu are completata localitatea"
msgstr ""

#. module: l10n_ro_edi_check
#: code:addons/l10n_ro_edi_check/models/account_move.py:0
#, python-format
msgid "Partenerul %s nu are completata strada"
msgstr ""

#. module: l10n_ro_edi_check
#: code:addons/l10n_ro_edi_check/models/account_move.py:0
#, python-format
msgid "Partenerul %s nu are completata tara"
msgstr ""

#. module: l10n_ro_edi_check
#: code:addons/l10n_ro_edi_check/models/account_move.py:0
#, python-format
msgid "localitatea pertenerului %s trebuie sa fie de forma SectorX "
msgstr ""
1 change: 0 additions & 1 deletion l10n_ro_edi_check/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
from . import account_move
from . import account_edi_document
from . import account_edi_format

25 changes: 12 additions & 13 deletions l10n_ro_edi_check/models/account_edi_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

import logging



from odoo import models


_logger = logging.getLogger(__name__)


Expand All @@ -19,15 +16,17 @@ def _find_value(self, xpath, xml_element, namespaces=None):
if namespaces is None:
namespaces = {}

namespaces.update({
"qdt": "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDataTypes-2",
"ccts": "urn:un:unece:uncefact:documentation:2",
"udt": "urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2",
"cac": "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2", # noqa: B950
"cbc": "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2",
"xsi": "http://www.w3.org/2001/XMLSchema-instance",
})

res = super(AccountEdiXmlCIUSRO, self)._find_value(xpath, xml_element, namespaces=namespaces)
namespaces.update(
{
"qdt": "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDataTypes-2",
"ccts": "urn:un:unece:uncefact:documentation:2",
"udt": "urn:oasis:names:specification:ubl:schema:xsd:UnqualifiedDataTypes-2",
"cac": "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2", # noqa: B950
"cbc": "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2",
"xsi": "http://www.w3.org/2001/XMLSchema-instance",
}
)

res = super()._find_value(xpath, xml_element, namespaces=namespaces)

return res
31 changes: 21 additions & 10 deletions l10n_ro_edi_check/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# © 2024-now Dan Stoica <danila(@)terrabit(.)ro
# See README.rst file on addons root folder for license details

from odoo import _, models
from odoo import _, api, fields, models
from odoo.exceptions import UserError


Expand All @@ -13,20 +13,21 @@ def action_post(self):
errors = []
for move in self:
if move.move_type in ["out_invoice", "out_refund"] and move.commercial_partner_id.is_company:
country_ro = self.env.ref("base.ro")
partner = move.commercial_partner_id
if not partner.country_id:
errors += [_("Partenerul %s nu are completata tara") % partner.name]
elif partner.country_id == country_ro:
if not partner.street:
errors += [_("Partenerul %s nu are completata strada") % partner.name]

if not partner.street:
errors += [_("Partenerul %s nu are completata strada") % partner.name]
if not partner.city:
errors += [_("Partenerul %s nu are completata localitatea") % partner.name]

if not partner.city:
errors += [_("Partenerul %s nu are completata localitatea") % partner.name]

state_bucuresti = self.env.ref("base.RO_B")
if partner.state_id == state_bucuresti and partner.city:
if "sector" not in partner.city.lower():
errors += [_("localitatea pertenerului %s trebuie sa fie de forma SectorX ") % partner.name]
state_bucuresti = self.env.ref("base.RO_B")
if partner.state_id == state_bucuresti and partner.city:
if "sector" not in partner.city.lower():
errors += [_("localitatea pertenerului %s trebuie sa fie de forma SectorX ") % partner.name]
if errors:
errors_text = "\n".join(errors)
raise UserError(errors_text)
Expand All @@ -36,6 +37,16 @@ def action_post(self):
class AccountMoveLine(models.Model):
_inherit = "account.move.line"

l10n_ro_label_length = fields.Integer(string="Desc. length", compute="_compute_label_length")

@api.onchange("product_id", "name")
def _compute_label_length(self):
for line in self:
if line.name:
line.l10n_ro_label_length = len(line.name)
else:
line.l10n_ro_label_length = 0

def _get_computed_price_unit(self):
self.ensure_one()
if self.move_id.move_type not in ["in_invoice", "in_refund"] or not self.move_id.l10n_ro_edi_download:
Expand Down
1 change: 1 addition & 0 deletions l10n_ro_edi_check/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Verificare date pentru trimitere ANAF la validarea facturii
- Implementare cu coada job-uri
- Dezactivare recalculare pret unitar la facuri furnizor cu ID eFactura
- Camp nr. caractere descriere in linie factura
3 changes: 2 additions & 1 deletion l10n_ro_edi_check/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,15 @@ <h1 class="title">Romania - EDI data check and queue</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:2670c0de37d5788be945fc1e758bacefbe751da939ce0d106cf680fb5013779d
!! source digest: sha256:567d8a867738841397769cb264a077e2abb0851f1e7478afe27edb36653d65eb
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/dhongu/l10n-romania/tree/15.0/l10n_ro_edi_check"><img alt="dhongu/l10n-romania" src="https://img.shields.io/badge/github-dhongu%2Fl10n--romania-lightgray.png?logo=github" /></a></p>
<blockquote>
<ul class="simple">
<li>Verificare date pentru trimitere ANAF la validarea facturii</li>
<li>Implementare cu coada job-uri</li>
<li>Dezactivare recalculare pret unitar la facuri furnizor cu ID eFactura</li>
<li>Camp nr. caractere descriere in linie factura</li>
</ul>
</blockquote>
<p><strong>Table of contents</strong></p>
Expand Down
27 changes: 27 additions & 0 deletions l10n_ro_edi_check/views/account_move.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" ?>
<odoo>
<data>
<record id="l10n_ro_invoice_form_view" model="ir.ui.view">
<field name="name">l10n_ro.account.invoice.form</field>
<field name="model">account.move</field>
<field name="type">form</field>
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='name']" position="after">
<field name="l10n_ro_label_length" optional="hide" />
</xpath>
</field>
</record>
<record id="view_invoice_tree" model="ir.ui.view">
<field name="name">l10n_ro.account.invoice.tree</field>
<field name="model">account.move</field>
<field name="type">tree</field>
<field name="inherit_id" ref="account.view_invoice_tree" />
<field name="arch" type="xml">
<field name="payment_state" position="after">
<field name="l10n_ro_edi_download" optional="hide" />
</field>
</field>
</record>
</data>
</odoo>

0 comments on commit ee02c8f

Please sign in to comment.