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

[18.0][IMP] Remove deprecated is_l10n_ro_record field and cleanup logic #1215

Closed
wants to merge 10 commits into from
12 changes: 9 additions & 3 deletions l10n_ro_config/i18n/ro.po
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ msgstr "Setări de configurare"
#. module: l10n_ro_config
#: model:ir.model,name:l10n_ro_config.model_res_partner
msgid "Contact"
msgstr "a lua legatura"
msgstr "Contact"

#. module: l10n_ro_config
#: model:ir.model.fields,field_description:l10n_ro_config.field_res_config_settings__module_l10n_ro_partner_create_by_vat
Expand Down Expand Up @@ -388,7 +388,7 @@ msgstr "Restricționați data mutarii stocului luna trecută"
#. module: l10n_ro_config
#: model_terms:ir.ui.view,arch_db:l10n_ro_config.res_config_settings_view_form
msgid "Restrict stock move posting in the last month."
msgstr ""
msgstr "Restricționați postarea mișcării stocurilor în ultima lună."

#. module: l10n_ro_config
#: model:ir.model.fields,help:l10n_ro_config.field_res_company__l10n_ro_restrict_stock_move_date_last_month
Expand Down Expand Up @@ -688,7 +688,7 @@ msgstr ""
#. module: l10n_ro_config
#: model_terms:ir.ui.view,arch_db:l10n_ro_config.res_config_settings_view_form
msgid "Select a expense account"
msgstr ""
msgstr "Selectați un cont de cheltuieli"

#. module: l10n_ro_config
#: model_terms:ir.ui.view,arch_db:l10n_ro_config.res_config_settings_view_form
Expand Down Expand Up @@ -776,6 +776,9 @@ msgid ""
"deductible. If the line account does not "
"have a non deductible account set, this account will be used."
msgstr ""
"Acest cont va fi utilizat ca cont implicit de cheltuieli nedeductibile din "
"liniile de repartizare a taxelor marcate ca nedeductibile. Dacă contul de "
"linie nu are setat un cont nedeductibil, acest cont va fi utilizat."

#. module: l10n_ro_config
#: model:ir.model.fields,help:l10n_ro_config.field_res_company__l10n_ro_nondeductible_account_id
Expand All @@ -785,6 +788,9 @@ msgid ""
"tax repartition lines marked as not deductible. If the line account does not "
"have a non deductible account set, this account will be used."
msgstr ""
"Acest cont va fi utilizat ca cont implicit de cheltuieli nedeductibile din "
"liniile de repartizare a taxelor marcate ca nedeductibile. Dacă contul de "
"linie nu are setat un cont nedeductibil, acest cont va fi utilizat."

#. module: l10n_ro_config
#: model:ir.model.fields,help:l10n_ro_config.field_res_company__l10n_ro_property_stock_picking_custody_account_id
Expand Down
19 changes: 19 additions & 0 deletions l10n_ro_config/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

from odoo import api, fields, models

SEQUENCE_TYPE = [
("normal", "Invoice"),
("autoinv1", "Customer Auto Invoicing"),
("autoinv2", "Supplier Auto Invoicing"),
]


class AccountJournal(models.Model):
_name = "account.journal"
Expand All @@ -17,6 +23,19 @@ class AccountJournal(models.Model):
)

l10n_ro_fiscal_receipt = fields.Boolean("Fiscal Receipts Journal")
l10n_ro_partner_id = fields.Many2one(
"res.partner", "Romania - Autoinvoice Partner", default=None
)
l10n_ro_sequence_type = fields.Selection(
selection=SEQUENCE_TYPE,
string="Romania - Autoinvoice Sequence Type",
default="normal",
)
l10n_ro_fiscal_position_id = fields.Many2one(
"account.fiscal.position",
"Romania - Fiscal Position",
domain="[('company_id', '=', company_id)]",
)

@api.depends("bank_account_id.l10n_ro_print_report")
def _compute_l10n_ro_print_report(self):
Expand Down
11 changes: 7 additions & 4 deletions l10n_ro_config/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _compute_l10n_ro_vat_number(self):
for partner in self:
l10n_ro_vat_number = ""
if partner.vat:
l10n_ro_vat_number = self._split_vat(partner.vat)[1]
l10n_ro_vat_number = self._split_vat_and_mapped_country(partner.vat)[1]
partner.l10n_ro_vat_number = l10n_ro_vat_number

def _l10n_ro_map_vat_country_code(self, country_code):
Expand All @@ -37,7 +37,7 @@ def _l10n_ro_map_vat_country_code(self, country_code):
}
return country_code_map.get(country_code, country_code)

def _split_vat(self, vat):
def _split_vat_and_mapped_country(self, vat):
# Allowing setting the vat without country code
vat_country = l10n_ro_vat_number = ""
if vat and vat.isdigit():
Expand All @@ -48,7 +48,7 @@ def _split_vat(self, vat):
partner.country_id.code.upper()
).lower()
else:
vat_country, l10n_ro_vat_number = super()._split_vat(vat)
vat_country, l10n_ro_vat_number = self._split_vat(vat)
return vat_country, l10n_ro_vat_number

@api.onchange("l10n_ro_vat_subjected")
Expand All @@ -65,5 +65,8 @@ def onchange_l10n_ro_vat_subjected(self):
and not self.vat.isdigit()
and not self.l10n_ro_vat_subjected
):
vat_country, l10n_ro_vat_number = self._split_vat(self.vat)
(
vat_country,
l10n_ro_vat_number,
) = self._split_vat_and_mapped_country(self.vat)
self.vat = l10n_ro_vat_number
12 changes: 10 additions & 2 deletions l10n_ro_config/views/account_journal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<field name="inherit_id" ref="account.view_account_journal_tree" />
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="is_l10n_ro_record" column_invisible="1" />
<field name="l10n_ro_print_report" />
</field>
</field>
Expand All @@ -17,9 +16,18 @@
<field name="inherit_id" ref="account.view_account_journal_form" />
<field name="arch" type="xml">
<xpath expr="//group/field[@name='company_id']" position="after">
<field name="is_l10n_ro_record" invisible="1" />
<field name="l10n_ro_print_report" readonly="False" />
<field name="l10n_ro_fiscal_receipt" />
<field name="l10n_ro_fiscal_position_id" />
</xpath>
<xpath expr="//group[@name='group_alias_edit']" position="after">
<group
string="Ro Auto Invoicing"
invisible="type not in ['sale', 'purchase']"
>
<field name="l10n_ro_sequence_type" />
<field name="l10n_ro_partner_id" />
</group>
</xpath>
</field>
</record>
Expand Down
2 changes: 0 additions & 2 deletions l10n_ro_config/views/res_bank_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<field name="inherit_id" ref="base.view_partner_bank_form" />
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="is_l10n_ro_record" invisible="1" />
<field name="l10n_ro_print_report" />
</field>
</field>
Expand All @@ -17,7 +16,6 @@
<field name="inherit_id" ref="base.view_partner_bank_tree" />
<field name="arch" type="xml">
<field name="company_id" position="after">
<field name="is_l10n_ro_record" invisible="1" />
<field name="l10n_ro_print_report" />
</field>
</field>
Expand Down
3 changes: 0 additions & 3 deletions l10n_ro_config/views/res_partner_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<form position="inside">
<field name="is_l10n_ro_record" invisible="1" />
</form>
<field name="nrc" position="attributes">
<attribute name="invisible">not is_company</attribute>
</field>
Expand Down
1 change: 0 additions & 1 deletion l10n_ro_config/wizard/res_config_settings_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<field name="inherit_id" ref="base.res_config_settings_view_form" />
<field name="arch" type="xml">
<form position="inside">
<field name="is_l10n_ro_record" invisible="1" />
<field
name="country_code"
invisible="1"
Expand Down
2 changes: 0 additions & 2 deletions l10n_ro_stock/views/stock_location_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<field name="inherit_id" ref="stock.view_location_form" />
<field name="arch" type="xml">
<field name="usage" position="after">
<field name="is_l10n_ro_record" invisible="1" />
<field name="l10n_ro_merchandise_type" />
</field>
</field>
Expand All @@ -27,7 +26,6 @@
<field name="inherit_id" ref="stock.view_location_tree2" />
<field name="arch" type="xml">
<field name="usage" position="after">
<field name="is_l10n_ro_record" column_invisible="1" />
<field name="l10n_ro_merchandise_type" />
</field>
</field>
Expand Down
1 change: 0 additions & 1 deletion l10n_ro_stock/views/stock_warehouse_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<field name="inherit_id" ref="stock.view_warehouse" />
<field name="arch" type="xml">
<field name="wh_output_stock_loc_id" position="after">
<field name="is_l10n_ro_record" invisible="1" />
<field name="l10n_ro_wh_consume_loc_id" readonly="1" />
<field name="l10n_ro_wh_usage_loc_id" readonly="1" />
</field>
Expand Down
2 changes: 1 addition & 1 deletion l10n_ro_stock_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"views/product_category_view.xml",
"views/product_template_view.xml",
"views/stock_location_view.xml",
# "views/stock_picking_view.xml",
"views/stock_picking_view.xml",
"views/stock_valuation_layer_views.xml",
"views/stock_warehouse_view.xml",
],
Expand Down
31 changes: 21 additions & 10 deletions l10n_ro_stock_account/i18n/ro.po
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ msgstr "Factură"
msgid "Is Romanian Record"
msgstr "Inregistrare românească"

#. module: l10n_ro_stock_account
#: model:ir.actions.act_window,name:l10n_ro_stock_account.l10n_ro_stock_account_move_action
msgid "Journal Entries"
msgstr "Înregistrări contabile"

#. module: l10n_ro_stock_account
#: model:ir.model,name:l10n_ro_stock_account.model_account_move
msgid "Journal Entry"
Expand All @@ -187,6 +192,16 @@ msgstr "Notă contabilă"
msgid "Journal Item"
msgstr "Element jurnal"

#. module: l10n_ro_stock_account
#: model_terms:ir.ui.view,arch_db:l10n_ro_stock_account.view_picking_add_price_unit_form
msgid "Journal Items"
msgstr "Elemente jurnal"

#. module: l10n_ro_stock_account
#: model:ir.model.fields,field_description:l10n_ro_stock_account.field_stock_picking_type__l10n_ro_fiscal_position_id
msgid "L10N Ro Fiscal Position"
msgstr ""

#. module: l10n_ro_stock_account
#: model:ir.model.fields.selection,name:l10n_ro_stock_account.selection__stock_valuation_layer__l10n_ro_valued_type__minus_inventory
msgid "Minus inventory"
Expand Down Expand Up @@ -236,6 +251,11 @@ msgstr "Categorie produs"
msgid "Production"
msgstr "Producție"

#. module: l10n_ro_stock_account
#: model:ir.actions.server,name:l10n_ro_stock_account.action_location_account_propagate
msgid "Propagate Accounts"
msgstr ""

#. module: l10n_ro_stock_account
#: model:ir.model.fields.selection,name:l10n_ro_stock_account.selection__stock_valuation_layer__l10n_ro_valued_type__reception
msgid "Reception"
Expand Down Expand Up @@ -330,7 +350,7 @@ msgstr ""
#. module: l10n_ro_stock_account
#: model:ir.model,name:l10n_ro_stock_account.model_stock_picking
msgid "Transfer"
msgstr ""
msgstr "Transfer"

#. module: l10n_ro_stock_account
#. odoo-python
Expand Down Expand Up @@ -362,12 +382,3 @@ msgstr "Tip evaluat"
#: model:ir.model,name:l10n_ro_stock_account.model_stock_warehouse
msgid "Warehouse"
msgstr ""

#~ msgid "Invoice Line"
#~ msgstr "Linie factură"

#~ msgid "Journal Entries"
#~ msgstr "Înregistrări contabile"

#~ msgid "Journal Items"
#~ msgstr "Elemente jurnal"
16 changes: 13 additions & 3 deletions l10n_ro_stock_account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,37 @@ def _compute_account_id(self):
fiscal_pos=fiscal_position
)
account = False
fiscal_position = line.move_id.fiscal_position_id
fiscal_positions = line.move_id.fiscal_position_id
if line.move_id.is_purchase_document():
account = accounts["stock_valuation"]
pickings = line.purchase_line_id.order_id.picking_ids
fiscal_positions |= pickings.mapped(
"picking_type_id.l10n_ro_fiscal_position_id"
)
stock_moves = line._get_account_change_stock_moves_purchase()
for stock_move in stock_moves:
location = stock_move.location_dest_id
va = location.l10n_ro_property_stock_valuation_account_id
if va:
account = va
if line.move_id.is_sale_document():
pickings = line.sale_line_ids.mapped("order_id.picking_ids")
fiscal_positions |= pickings.mapped(
"picking_type_id.l10n_ro_fiscal_position_id"
)
stock_moves = line._get_account_change_stock_moves_sale()
for stock_move in stock_moves:
location = stock_move.location_id
ai = location.l10n_ro_property_account_income_location_id
if ai:
account = ai
if fiscal_position:
account = fiscal_position.map_account(account)
fiscal_positions |= line.move_id.journal_id.l10n_ro_fiscal_position_id
for fiscal_position in fiscal_positions:
account = fiscal_position.map_account(account or line.account_id)

if account:
line.account_id = account

return res

def _get_account_change_stock_moves_purchase(self):
Expand Down
4 changes: 4 additions & 0 deletions l10n_ro_stock_account/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class ProductTemplate(models.Model):
"use the category value. ",
)

def get_product_accounts(self, fiscal_pos=None):
fiscal_pos = fiscal_pos or self.env.context.get("fiscal_pos")
return super().get_product_accounts(fiscal_pos)

def _get_product_accounts(self):
accounts = super()._get_product_accounts()

Expand Down
12 changes: 12 additions & 0 deletions l10n_ro_stock_account/models/stock_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,15 @@ def _should_be_valued(self):
if self.env.context.get("valued_type") == "internal_transit_out":
res = False
return res

def propagate_account(self):
for location in self:
children = self.search([("id", "child_of", [location.id])])
if not children:
continue
values = {
"l10n_ro_property_account_income_location_id": location.l10n_ro_property_account_income_location_id.id, # noqa
"l10n_ro_property_account_expense_location_id": location.l10n_ro_property_account_expense_location_id.id, # noqa
"l10n_ro_property_stock_valuation_account_id": location.l10n_ro_property_stock_valuation_account_id.id, # noqa
}
children.write(values)
Loading
Loading