Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0] [FIX] l10n_it_withholding_tax: fix for #2345 #2351

Conversation

TheMule71
Copy link
Contributor

Per la descrizione del problema vd. #2345

--
Confermo di aver firmato il CLA https://odoo-community.org/page/cla e di aver letto le linee guida su https://odoo-community.org/page/contributing

TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 2, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 2, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 2, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 2, 2021
@eLBati eLBati changed the title [FIX] l10n_it_withholding_tax: fix for #2345 [14.0] [FIX] l10n_it_withholding_tax: fix for #2345 Jul 2, 2021
misc_journal = self.env["account.journal"].search([("code", "=", _("MISC"))])
misc_journal = self.env["account.journal"].search(
[("code", "=", _("MISC")), ("company_id", "=", self.company_id.id)]
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non ci sono già le record rules che mostrano solo i record della company corrente?

Copy link
Contributor Author

@TheMule71 TheMule71 Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voi dite questa:

<record id="journal_comp_rule" model="ir.rule">
        <field name="name">Journal multi-company</field>
        <field name="model_id" ref="model_account_journal"/>
        <field name="domain_force">['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
</record>

?

Magari capisco male io ma qui company_id viene matchato in company_ids, ossia le company alle quali l'utente ha accesso, come permessi. Nella issue in questione, l'utente ha effettivamente accesso a più company.

Il problema qui non è di permessi, ma il fatto che viene beccato il primo conto con code _("MISC") ossia "VARIE" per noi, indipendentemente dalla company sulla quale si sta operando. Se l'utente ha accesso ad una sola company, o se per caso il conto che becca è quello giusto, il problema non si manifesta.

Dobbiamo trovare il conto giusto, quello della company corrente su cui l'iutente sta operando.

Copy link
Member

@SimoRubi SimoRubi Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok quindi l'utente ha accesso a più company quindi vengono beccati tutti i sezionali delle company cui può accedere.
Onestamente ricordavo che la rule facesse vedere solo i sezionali dell'azienda dell'utente (ma è in v12: https://github.com/odoo/odoo/blob/49eb24a46771792bec454f6c4693c19d2b5b05b6/addons/account/security/account_security.xml#L105-L110).

In questo caso secondo me va bene filtrare per la company corrente ma dovresti usare self.env.company perché durante il calcolo dei default, self non ha dati al suo interno ; o meglio: dipendono solo dagli altri default https://github.com/odoo/odoo/blob/72fea2fe11244a55e9a630049fc75f147e26e473/odoo/models.py#L1263-L1328 ma per semplicità lo supporrei senza dati perché https://github.com/odoo/odoo/blob/72fea2fe11244a55e9a630049fc75f147e26e473/odoo/models.py#L1263-L1328 è un api.model

Copy link
Member

@SimoRubi SimoRubi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revisione del codice.
Riesci ad aggiungere un test?

EDIT: ci sarebbe anche da controllare com mai falliscono tutti i test di Traivs

misc_journal = self.env["account.journal"].search([("code", "=", _("MISC"))])
misc_journal = self.env["account.journal"].search(
[("code", "=", _("MISC")), ("company_id", "=", self.company_id.id)]
)
Copy link
Member

@SimoRubi SimoRubi Jul 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok quindi l'utente ha accesso a più company quindi vengono beccati tutti i sezionali delle company cui può accedere.
Onestamente ricordavo che la rule facesse vedere solo i sezionali dell'azienda dell'utente (ma è in v12: https://github.com/odoo/odoo/blob/49eb24a46771792bec454f6c4693c19d2b5b05b6/addons/account/security/account_security.xml#L105-L110).

In questo caso secondo me va bene filtrare per la company corrente ma dovresti usare self.env.company perché durante il calcolo dei default, self non ha dati al suo interno ; o meglio: dipendono solo dagli altri default https://github.com/odoo/odoo/blob/72fea2fe11244a55e9a630049fc75f147e26e473/odoo/models.py#L1263-L1328 ma per semplicità lo supporrei senza dati perché https://github.com/odoo/odoo/blob/72fea2fe11244a55e9a630049fc75f147e26e473/odoo/models.py#L1263-L1328 è un api.model

@TheMule71
Copy link
Contributor Author

Mi sono appena reso conto di aver creato 2 PR per lo stesso file e quasi lo stesso motivo, mergio questa in #2353 e chiudo.

@SimoRubi ho fatto la modifica anche se prima era stata testata e funzionava, segno che self.company_id.id era popolato.

I test sembrano fallire per un problema di fatturapa_in, da provare a mergiare la #2352 e poi facendo un rebase vedere se questa è verde.

@TheMule71 TheMule71 closed this Jul 2, 2021
@francescapenso
Copy link

ciao, i sa che con l'ultimo merge si è perso qualcosa perchè adesso ho provato conl'ultimo e non funziona come prima.
se guardo il codice adesso c'è su questo

misc_journal = self.env["account.journal"].search(
[("code", "=", _("MISC")), ("company_id", "=", self.env.company.id)]
)
if misc_journal:
return misc_journal[0].id
return False

mentre quello che avevamo testato e funzionava era questo

def _default_wt_journal(self):
misc_journal = self.env["account.journal"].search(
[("code", "=", _("MISC")), ("company_id", "=", self.company_id.id)]
)
if misc_journal:
return misc_journal[0].id
return False

Mi è sfuggito qualcosa?

TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 9, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 9, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 9, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 9, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 17, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 20, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 30, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jul 30, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Aug 6, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Aug 20, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Sep 3, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Sep 17, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Oct 1, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Oct 8, 2021
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Oct 15, 2021
TheMule71 added a commit to TheMule71/l10n-italy that referenced this pull request Jan 21, 2022
TheMule71 added a commit to TheMule71/l10n-italy that referenced this pull request Jan 21, 2022
TheMule71 added a commit to odoo-italia/l10n-italy that referenced this pull request Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants