Add origin in warning of missing analytics when post an account move

This commit is contained in:
carlosgalvez-nan 2020-03-10 16:03:33 +01:00
parent 8f143b0a68
commit 9c58c3f2f4
4 changed files with 184 additions and 33 deletions

View file

@ -121,12 +121,16 @@ class Account(metaclass=PoolMeta):
class Move(metaclass=PoolMeta): class Move(metaclass=PoolMeta):
__name__ = 'account.move' __name__ = 'account.move'
@classmethod @classmethod
@ModelView.button @ModelView.button
def post(cls, moves): def post(cls, moves):
super(Move, cls).post(moves) super(Move, cls).post(moves)
for move in moves: for move in moves:
origin = ''
origin_model = ''
if move.origin:
origin = move.origin.rec_name
origin_model = move.origin.__names__().get('model')
if move.period.type == 'adjustment': if move.period.type == 'adjustment':
continue continue
for line in move.lines: for line in move.lines:
@ -139,8 +143,9 @@ class Move(metaclass=PoolMeta):
line.account.name), line.account.name),
roots=', '.join(r.rec_name roots=', '.join(r.rec_name
for r in required_roots), for r in required_roots),
origin=origin,
origin_model=origin_model,
)) ))
for analytic_line in line.analytic_lines: for analytic_line in line.analytic_lines:
if analytic_line.account.root in required_roots: if analytic_line.account.root in required_roots:
required_roots.remove(analytic_line.account.root) required_roots.remove(analytic_line.account.root)
@ -162,6 +167,8 @@ class Move(metaclass=PoolMeta):
line.account.name), line.account.name),
roots=', '.join(r.rec_name roots=', '.join(r.rec_name
for r in required_roots), for r in required_roots),
origin=origin,
origin_model=origin_model,
)) ))

View file

@ -47,6 +47,31 @@ msgctxt ""
msgid "Analytic Account" msgid "Analytic Account"
msgstr "Compte analític" msgstr "Compte analític"
msgctxt ""
"field:analytic_account.account-forbidden-account.account,create_date:"
msgid "Create Date"
msgstr "Data de creació"
msgctxt "field:analytic_account.account-forbidden-account.account,create_uid:"
msgid "Create User"
msgstr "Usuari de creació"
msgctxt "field:analytic_account.account-forbidden-account.account,id:"
msgid "ID"
msgstr "Identificació"
msgctxt "field:analytic_account.account-forbidden-account.account,rec_name:"
msgid "Name"
msgstr "Nom registre"
msgctxt "field:analytic_account.account-forbidden-account.account,write_date:"
msgid "Write Date"
msgstr "Data de modificació"
msgctxt "field:analytic_account.account-forbidden-account.account,write_uid:"
msgid "Write User"
msgstr "Usuari de modificació"
msgctxt "field:analytic_account.account-optional-account.account,account:" msgctxt "field:analytic_account.account-optional-account.account,account:"
msgid "Account" msgid "Account"
msgstr "Compte" msgstr "Compte"
@ -56,6 +81,30 @@ msgctxt ""
msgid "Analytic Account" msgid "Analytic Account"
msgstr "Compte analític" msgstr "Compte analític"
msgctxt "field:analytic_account.account-optional-account.account,create_date:"
msgid "Create Date"
msgstr "Data de creació"
msgctxt "field:analytic_account.account-optional-account.account,create_uid:"
msgid "Create User"
msgstr "Usuari de creació"
msgctxt "field:analytic_account.account-optional-account.account,id:"
msgid "ID"
msgstr "Identificació"
msgctxt "field:analytic_account.account-optional-account.account,rec_name:"
msgid "Name"
msgstr "Nom registre"
msgctxt "field:analytic_account.account-optional-account.account,write_date:"
msgid "Write Date"
msgstr "Data de modificació"
msgctxt "field:analytic_account.account-optional-account.account,write_uid:"
msgid "Write User"
msgstr "Usuari de modificació"
msgctxt "field:analytic_account.account-required-account.account,account:" msgctxt "field:analytic_account.account-required-account.account,account:"
msgid "Account" msgid "Account"
msgstr "Compte" msgstr "Compte"
@ -65,6 +114,30 @@ msgctxt ""
msgid "Analytic Account" msgid "Analytic Account"
msgstr "Compte analític" msgstr "Compte analític"
msgctxt "field:analytic_account.account-required-account.account,create_date:"
msgid "Create Date"
msgstr "Data de creació"
msgctxt "field:analytic_account.account-required-account.account,create_uid:"
msgid "Create User"
msgstr "Usuari de creació"
msgctxt "field:analytic_account.account-required-account.account,id:"
msgid "ID"
msgstr "Identificació"
msgctxt "field:analytic_account.account-required-account.account,rec_name:"
msgid "Name"
msgstr "Nom registre"
msgctxt "field:analytic_account.account-required-account.account,write_date:"
msgid "Write Date"
msgstr "Data de modificació"
msgctxt "field:analytic_account.account-required-account.account,write_uid:"
msgid "Write User"
msgstr "Usuari de modificació"
msgctxt "field:analytic_account.line,company:" msgctxt "field:analytic_account.line,company:"
msgid "Company" msgid "Company"
msgstr "Empresa" msgstr "Empresa"
@ -107,7 +180,7 @@ msgstr "Compte analític - Compte - Requerit"
msgctxt "model:ir.message,text:account_analytic_not_configured" msgctxt "model:ir.message,text:account_analytic_not_configured"
msgid "" msgid ""
"The Move Line \"%(line)s\" is related to the Account \"%(account)s\" which " "Move Line \"%(line)s\" is related to the Account \"%(account)s\" which "
"is not configured for all Analytic hierarchies" "is not configured for all Analytic hierarchies"
msgstr "" msgstr ""
"L'apunt \"%(line)s\" està associat al compte \"%(account)s\" el qual no està" "L'apunt \"%(line)s\" està associat al compte \"%(account)s\" el qual no està"
@ -115,7 +188,7 @@ msgstr ""
msgctxt "model:ir.message,text:analytic_account_forbidden_optional" msgctxt "model:ir.message,text:analytic_account_forbidden_optional"
msgid "" msgid ""
"The Account \"%(account)s\" has configured the next Analytic Roots as " "Account \"%(account)s\" has configured the next Analytic Roots as "
"Forbidden and Optional at once: %(roots)s." "Forbidden and Optional at once: %(roots)s."
msgstr "" msgstr ""
"El compte \"%(account)s\" té configurades les següents jerarquies " "El compte \"%(account)s\" té configurades les següents jerarquies "
@ -123,7 +196,7 @@ msgstr ""
msgctxt "model:ir.message,text:analytic_account_required_forbidden" msgctxt "model:ir.message,text:analytic_account_required_forbidden"
msgid "" msgid ""
"The Account \"%(account)s\" has configured the next Analytic Roots as " "Account \"%(account)s\" has configured the next Analytic Roots as "
"Required and Forbidden at once: %(roots)s." "Required and Forbidden at once: %(roots)s."
msgstr "" msgstr ""
"El compte \"%(account)s\" té configurades les següents jerarquies " "El compte \"%(account)s\" té configurades les següents jerarquies "
@ -131,7 +204,7 @@ msgstr ""
msgctxt "model:ir.message,text:analytic_account_required_optional" msgctxt "model:ir.message,text:analytic_account_required_optional"
msgid "" msgid ""
"The Account \"%(account)s\" has configured the next Analytic Roots as " "Account \"%(account)s\" has configured the next Analytic Roots as "
"Required and Optional at once: %(roots)s." "Required and Optional at once: %(roots)s."
msgstr "" msgstr ""
"El compte \"%(account)s\" té configurades les següents jerarquies " "El compte \"%(account)s\" té configurades les següents jerarquies "
@ -139,7 +212,7 @@ msgstr ""
msgctxt "model:ir.message,text:invalid_analytic_to_post_move" msgctxt "model:ir.message,text:invalid_analytic_to_post_move"
msgid "" msgid ""
"The Account Move \"%(move)s\" can't be posted because the Analytic Lines of " "Account Move \"%(move)s\" can't be posted because the Analytic Lines of "
"hierachy \"%(root)s\" related to Move Line \"%(line)s\" are not valid." "hierachy \"%(root)s\" related to Move Line \"%(line)s\" are not valid."
msgstr "" msgstr ""
"L'assentament \"%(move)s\" no pot ser confirmat perque les línies " "L'assentament \"%(move)s\" no pot ser confirmat perque les línies "
@ -148,17 +221,16 @@ msgstr ""
msgctxt "model:ir.message,text:missing_analytic_lines" msgctxt "model:ir.message,text:missing_analytic_lines"
msgid "" msgid ""
"The Account Move \"%(move)s\" can't be posted because it doesn't have " "Account Move \"%(move)s\" with origin %(origin_model)s \"%(origin)s\" can't be posted because it doesn't have analytic lines for the next required analytic hierachies: %(roots)s.\n"
"analytic lines for the next required analytic hierachies: %(roots)s." " For the account %(account)s."
"\nFor the account %(account)s"
msgstr "" msgstr ""
"L'assentament \"%(move)s\" no es pot validar perquè no te línies analítiques" "L'assentament \"%(move)s\" amb origen %(origin_model)s %(origin)s no es pot "
" de les següents jerarquies obligatories \"%(roots)s\"." "validar perquè no te línies analítiques de les següents jerarquies "
"\nPer la compte %(account)s" "obligatories \"%(roots)s\".Pel compte %(account)s"
msgctxt "model:ir.message,text:move_line_account_analytic_forbidden" msgctxt "model:ir.message,text:move_line_account_analytic_forbidden"
msgid "" msgid ""
"The Analytic Line \"%(line)s\" is related to an Account Move Line of Account" "Analytic Line \"%(line)s\" is related to an Account Move Line of Account"
" \"%(account)s\" which has the analytics forbidden for the Line\\'s Analytic" " \"%(account)s\" which has the analytics forbidden for the Line\\'s Analytic"
" hierarchy." " hierarchy."
msgstr "" msgstr ""

View file

@ -47,6 +47,31 @@ msgctxt ""
msgid "Analytic Account" msgid "Analytic Account"
msgstr "Cuenta analítica" msgstr "Cuenta analítica"
msgctxt ""
"field:analytic_account.account-forbidden-account.account,create_date:"
msgid "Create Date"
msgstr "Fecha de creación"
msgctxt "field:analytic_account.account-forbidden-account.account,create_uid:"
msgid "Create User"
msgstr "Usuario de creación"
msgctxt "field:analytic_account.account-forbidden-account.account,id:"
msgid "ID"
msgstr "Identificador"
msgctxt "field:analytic_account.account-forbidden-account.account,rec_name:"
msgid "Name"
msgstr "Nombre registro"
msgctxt "field:analytic_account.account-forbidden-account.account,write_date:"
msgid "Write Date"
msgstr "Fecha modificación"
msgctxt "field:analytic_account.account-forbidden-account.account,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
msgctxt "field:analytic_account.account-optional-account.account,account:" msgctxt "field:analytic_account.account-optional-account.account,account:"
msgid "Account" msgid "Account"
msgstr "Cuenta" msgstr "Cuenta"
@ -56,6 +81,30 @@ msgctxt ""
msgid "Analytic Account" msgid "Analytic Account"
msgstr "Cuenta analítica" msgstr "Cuenta analítica"
msgctxt "field:analytic_account.account-optional-account.account,create_date:"
msgid "Create Date"
msgstr "Fecha de creación"
msgctxt "field:analytic_account.account-optional-account.account,create_uid:"
msgid "Create User"
msgstr "Usuario de creación"
msgctxt "field:analytic_account.account-optional-account.account,id:"
msgid "ID"
msgstr "Identificador"
msgctxt "field:analytic_account.account-optional-account.account,rec_name:"
msgid "Name"
msgstr "Nombre registro"
msgctxt "field:analytic_account.account-optional-account.account,write_date:"
msgid "Write Date"
msgstr "Fecha modificación"
msgctxt "field:analytic_account.account-optional-account.account,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
msgctxt "field:analytic_account.account-required-account.account,account:" msgctxt "field:analytic_account.account-required-account.account,account:"
msgid "Account" msgid "Account"
msgstr "Cuenta" msgstr "Cuenta"
@ -65,6 +114,30 @@ msgctxt ""
msgid "Analytic Account" msgid "Analytic Account"
msgstr "Cuenta analítica" msgstr "Cuenta analítica"
msgctxt "field:analytic_account.account-required-account.account,create_date:"
msgid "Create Date"
msgstr "Fecha de creación"
msgctxt "field:analytic_account.account-required-account.account,create_uid:"
msgid "Create User"
msgstr "Usuario de creación"
msgctxt "field:analytic_account.account-required-account.account,id:"
msgid "ID"
msgstr "Identificador"
msgctxt "field:analytic_account.account-required-account.account,rec_name:"
msgid "Name"
msgstr "Nombre registro"
msgctxt "field:analytic_account.account-required-account.account,write_date:"
msgid "Write Date"
msgstr "Fecha modificación"
msgctxt "field:analytic_account.account-required-account.account,write_uid:"
msgid "Write User"
msgstr "Usuario modificación"
msgctxt "field:analytic_account.line,company:" msgctxt "field:analytic_account.line,company:"
msgid "Company" msgid "Company"
msgstr "Empresa" msgstr "Empresa"
@ -107,7 +180,7 @@ msgstr "Cuenta analítica - Cuenta - Requerida"
msgctxt "model:ir.message,text:account_analytic_not_configured" msgctxt "model:ir.message,text:account_analytic_not_configured"
msgid "" msgid ""
"The Move Line \"%(line)s\" is related to the Account \"%(account)s\" which " "Move Line \"%(line)s\" is related to the Account \"%(account)s\" which "
"is not configured for all Analytic hierarchies" "is not configured for all Analytic hierarchies"
msgstr "" msgstr ""
"El apunte \"%(line)s\" está asociado a la cuenta \"%(account)s\" la cual no " "El apunte \"%(line)s\" está asociado a la cuenta \"%(account)s\" la cual no "
@ -115,7 +188,7 @@ msgstr ""
msgctxt "model:ir.message,text:analytic_account_forbidden_optional" msgctxt "model:ir.message,text:analytic_account_forbidden_optional"
msgid "" msgid ""
"The Account \"%(account)s\" has configured the next Analytic Roots as " "Account \"%(account)s\" has configured the next Analytic Roots as "
"Forbidden and Optional at once: %(roots)s." "Forbidden and Optional at once: %(roots)s."
msgstr "" msgstr ""
"La cuenta \"%(account)s\" tiene configuradas las siguientes jerarquías " "La cuenta \"%(account)s\" tiene configuradas las siguientes jerarquías "
@ -123,7 +196,7 @@ msgstr ""
msgctxt "model:ir.message,text:analytic_account_required_forbidden" msgctxt "model:ir.message,text:analytic_account_required_forbidden"
msgid "" msgid ""
"The Account \"%(account)s\" has configured the next Analytic Roots as " "Account \"%(account)s\" has configured the next Analytic Roots as "
"Required and Forbidden at once: %(roots)s." "Required and Forbidden at once: %(roots)s."
msgstr "" msgstr ""
"La cuenta \"%(account)s\" tiene configuradas las siguientes jerarquías " "La cuenta \"%(account)s\" tiene configuradas las siguientes jerarquías "
@ -131,7 +204,7 @@ msgstr ""
msgctxt "model:ir.message,text:analytic_account_required_optional" msgctxt "model:ir.message,text:analytic_account_required_optional"
msgid "" msgid ""
"The Account \"%(account)s\" has configured the next Analytic Roots as " "Account \"%(account)s\" has configured the next Analytic Roots as "
"Required and Optional at once: %(roots)s." "Required and Optional at once: %(roots)s."
msgstr "" msgstr ""
"La cuenta \"%(account)s\" tiene configuradas las siguientes jerarquías " "La cuenta \"%(account)s\" tiene configuradas las siguientes jerarquías "
@ -139,7 +212,7 @@ msgstr ""
msgctxt "model:ir.message,text:invalid_analytic_to_post_move" msgctxt "model:ir.message,text:invalid_analytic_to_post_move"
msgid "" msgid ""
"The Account Move \"%(move)s\" can't be posted because the Analytic Lines of " "Account Move \"%(move)s\" can't be posted because the Analytic Lines of "
"hierachy \"%(root)s\" related to Move Line \"%(line)s\" are not valid." "hierachy \"%(root)s\" related to Move Line \"%(line)s\" are not valid."
msgstr "" msgstr ""
"El asiento \"%(move)s\" no se puede confirmar porque las líneas analíticas " "El asiento \"%(move)s\" no se puede confirmar porque las líneas analíticas "
@ -148,17 +221,15 @@ msgstr ""
msgctxt "model:ir.message,text:missing_analytic_lines" msgctxt "model:ir.message,text:missing_analytic_lines"
msgid "" msgid ""
"The Account Move \"%(move)s\" can't be posted because it doesn't have " "Account Move \"%(move)s\" with origin %(origin_model)s \"%(origin)s\" can't be posted because it doesn't have analytic lines for the next required analytic hierachies: %(roots)s.\n"
"analytic lines for the next required analytic hierachies: %(roots)s." " For the account %(account)s."
"\nFor the account %(account)s"
msgstr "" msgstr ""
"El asiento \"%(move)s\" no se puede validar porqué no tiene líneas " "El asiento \"%(move)s\" con origen %(origin_model)s \"%(origin)s\" no se puede validar porqué no tiene líneas analíticas para las siguientes jerarquías obligatorias: %(roots)s.\n"
"analíticas para las siguientes jerarquías obligatorias: %(roots)s." "Para la cuenta %(account)s"
"\nPara la cuenta %(account)s"
msgctxt "model:ir.message,text:move_line_account_analytic_forbidden" msgctxt "model:ir.message,text:move_line_account_analytic_forbidden"
msgid "" msgid ""
"The Analytic Line \"%(line)s\" is related to an Account Move Line of Account" "Analytic Line \"%(line)s\" is related to an Account Move Line of Account"
" \"%(account)s\" which has the analytics forbidden for the Line\\'s Analytic" " \"%(account)s\" which has the analytics forbidden for the Line\\'s Analytic"
" hierarchy." " hierarchy."
msgstr "" msgstr ""

View file

@ -4,25 +4,26 @@ this repository contains the full copyright notices and license terms. -->
<tryton> <tryton>
<data grouped="1"> <data grouped="1">
<record model="ir.message" id="analytic_account_required_forbidden"> <record model="ir.message" id="analytic_account_required_forbidden">
<field name="text">The Account "%(account)s" has configured the next Analytic Roots as Required and Forbidden at once: %(roots)s.</field> <field name="text">Account "%(account)s" has configured the next Analytic Roots as Required and Forbidden at once: %(roots)s.</field>
</record> </record>
<record model="ir.message" id="analytic_account_required_optional"> <record model="ir.message" id="analytic_account_required_optional">
<field name="text">The Account "%(account)s" has configured the next Analytic Roots as Required and Optional at once: %(roots)s.</field> <field name="text">Account "%(account)s" has configured the next Analytic Roots as Required and Optional at once: %(roots)s.</field>
</record> </record>
<record model="ir.message" id="analytic_account_forbidden_optional"> <record model="ir.message" id="analytic_account_forbidden_optional">
<field name="text">The Account "%(account)s" has configured the next Analytic Roots as Forbidden and Optional at once: %(roots)s.</field> <field name="text">Account "%(account)s" has configured the next Analytic Roots as Forbidden and Optional at once: %(roots)s.</field>
</record> </record>
<record model="ir.message" id="missing_analytic_lines"> <record model="ir.message" id="missing_analytic_lines">
<field name="text">The Account Move "%(move)s" can't be posted because it doesn't have analytic lines for the next required analytic hierachies: %(roots)s.\nFor the account %(account)s.</field> <field name="text">Account Move "%(move)s" with origin %(origin_model)s "%(origin)s" can't be posted because it doesn't have analytic lines for the next required analytic hierachies: %(roots)s.
For the account %(account)s.</field>
</record> </record>
<record model="ir.message" id="invalid_analytic_to_post_move"> <record model="ir.message" id="invalid_analytic_to_post_move">
<field name="text">The Account Move "%(move)s" can't be posted because the Analytic Lines of hierachy "%(root)s" related to Move Line "%(line)s" are not valid.</field> <field name="text">Account Move "%(move)s" can't be posted because the Analytic Lines of hierachy "%(root)s" related to Move Line "%(line)s" are not valid.</field>
</record> </record>
<record model="ir.message" id="account_analytic_not_configured"> <record model="ir.message" id="account_analytic_not_configured">
<field name="text">The Move Line "%(line)s" is related to the Account "%(account)s" which is not configured for all Analytic hierarchies</field> <field name="text">Move Line "%(line)s" is related to the Account "%(account)s" which is not configured for all Analytic hierarchies</field>
</record> </record>
<record model="ir.message" id="move_line_account_analytic_forbidden"> <record model="ir.message" id="move_line_account_analytic_forbidden">
<field name="text">The Analytic Line "%(line)s" is related to an Account Move Line of Account "%(account)s" which has the analytics forbidden for the Line\'s Analytic hierarchy.</field> <field name="text">Analytic Line "%(line)s" is related to an Account Move Line of Account "%(account)s" which has the analytics forbidden for the Line\'s Analytic hierarchy.</field>
</record> </record>
</data> </data>
</tryton> </tryton>