[IMP] l10n_in: set partner state in Place of supply only when journal type is sale

Currently, the Place of supply value is set from the partner state for all journal types.

So in this commit, we set the partner state in `Place of supply` only when
the journal type is a sale. Also added the country domain in XML view.

Part-of: odoo/odoo#109717
This commit is contained in:
bat-odoo
2023-01-16 10:32:17 +01:00
committed by Josse Colpaert
parent 68207af83c
commit 361ac275c7
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -37,10 +37,10 @@ class AccountMove(models.Model):
for record in self:
record.l10n_in_gst_treatment = record.partner_id.l10n_in_gst_treatment
@api.depends('partner_id')
@api.depends('partner_id', 'company_id')
def _compute_l10n_in_state_id(self):
for move in self:
if move.country_code == 'IN':
if move.country_code == 'IN' and move.journal_id.type == 'sale':
country_code = move.partner_id.country_id.code
if country_code == 'IN':
move.l10n_in_state_id = move.partner_id.state_id
@@ -48,6 +48,8 @@ class AccountMove(models.Model):
move.l10n_in_state_id = self.env.ref('l10n_in.state_in_oc', raise_if_not_found=False)
else:
move.l10n_in_state_id = move.company_id.state_id
elif move.country_code == 'IN' and move.journal_id.type == 'purchase':
move.l10n_in_state_id = move.company_id.state_id
else:
move.l10n_in_state_id = False
@@ -7,7 +7,7 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='ref']" position="after">
<field name="country_code" invisible="1"/>
<field name="l10n_in_state_id"
<field name="l10n_in_state_id" domain="[('country_id.code', '=', 'IN')]"
attrs="{'invisible': ['|', ('country_code', '!=', 'IN'), ('move_type', '=', 'entry')], 'required': [('country_code', '=', 'IN'), ('move_type', '!=', 'entry')], 'readonly': [('state', '!=', 'draft')]}"/>
<field name="l10n_in_gst_treatment"
attrs="{'invisible': ['|', ('country_code', '!=', 'IN'), ('move_type', '=', 'entry')], 'required': [('country_code', '=', 'IN'), ('move_type', '!=', 'entry')], 'readonly': [('state', '!=', 'draft')]}"/>