diff --git a/l10n_fr_department_state/__init__.py b/l10n_fr_department_state/__init__.py new file mode 100644 index 0000000..a0fdc10 --- /dev/null +++ b/l10n_fr_department_state/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import models diff --git a/l10n_fr_department_state/__manifest__.py b/l10n_fr_department_state/__manifest__.py new file mode 100644 index 0000000..f253b0f --- /dev/null +++ b/l10n_fr_department_state/__manifest__.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). +{ + "name": "Partner department state", + "version": "1.0.0", + "summary": "Get state from department (FR)", + "description": "", + "author": "RemiFr82", + "contributors": "", + "maintainer": "RemiFr82", + "website": "https://remifr82.me", + "license": "LGPL-3", + "category": "", + # "price": 0, + # "currency": "EUR", + "application": False, + "installable": True, + "auto_install": False, + # "pre_init_hook": "", + # "post_init_hook": "", + # "uninstall_hook": "", + # "excludes": [], + # "external_dependencies": [], + "depends": [ + "l10n_fr_department", + ], + "data": [ + # Views + "views/res_partner.xml", + ], + # "assets": [], + # "css": [], + # "images": [], + # "js": [], + # "test": [], + # "demo": [], +} diff --git a/l10n_fr_department_state/i18n/fr.po b/l10n_fr_department_state/i18n/fr.po new file mode 100644 index 0000000..4c8e5a2 --- /dev/null +++ b/l10n_fr_department_state/i18n/fr.po @@ -0,0 +1,27 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_fr_department_state +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0-20230613\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-05-26 14:23+0000\n" +"PO-Revision-Date: 2024-05-26 14:23+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_fr_department_state +#: model:ir.model,name:l10n_fr_department_state.model_res_partner +msgid "Contact" +msgstr "" + +#. module: l10n_fr_department_state +#: model:ir.model.fields,field_description:l10n_fr_department_state.field_res_partner__state_id +#: model:ir.model.fields,field_description:l10n_fr_department_state.field_res_users__state_id +msgid "State" +msgstr "RĂ©gion" diff --git a/l10n_fr_department_state/models/__init__.py b/l10n_fr_department_state/models/__init__.py new file mode 100644 index 0000000..0fbdfcf --- /dev/null +++ b/l10n_fr_department_state/models/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import res_partner diff --git a/l10n_fr_department_state/models/res_partner.py b/l10n_fr_department_state/models/res_partner.py new file mode 100644 index 0000000..50e4c13 --- /dev/null +++ b/l10n_fr_department_state/models/res_partner.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +import logging +from odoo import models, fields, api, tools + +_logger = logging.getLogger(__name__) + + +class ResPartner(models.Model): + _inherit = "res.partner" + + state_id = fields.Many2one( + compute="_compute_country_depatemnt", + store=True, + ) + + @api.depends("country_department_id") + def _compute_country_depatemnt(self): + for partner in self: + dept = partner.country_department_id + dept_stat = dept.state_id + if dept and dept_stat and not partner.state_id: + partner.state_id = dept_stat diff --git a/l10n_fr_department_state/views/res_partner.xml b/l10n_fr_department_state/views/res_partner.xml new file mode 100644 index 0000000..63ba0a3 --- /dev/null +++ b/l10n_fr_department_state/views/res_partner.xml @@ -0,0 +1,19 @@ + + + + + res.partner.view.form.inherit + res.partner + + + + {'readonly':[('country_department_id','!=',False)]} + {'no_open':1} + + + {'no_open':1} + + + + + \ No newline at end of file