[IMP] purchase,sale,l10n_in_[sale|purchase]: remove l10n_in_company_country_code field
1. Create a PO from Indian vendor [DEMO], confirm it, receive the products.
2. Go to Accounting app, manually create the vendor bill:
- select the Vendor [DEMO]
- in auto-complete field select the one created at 1.
Traceback will raise because the field l10n_in_company_country_code
was removed from account.move in
17610e8ca9
opw-2745052
closes odoo/odoo#85501
X-original-commit: ffbfdde4b5b4cd791e866341a31cdf5e8aeb27e3
Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -10,7 +10,7 @@ class AccountMove(models.Model):
|
||||
@api.onchange('purchase_vendor_bill_id', 'purchase_id')
|
||||
def _onchange_purchase_auto_complete(self):
|
||||
purchase_order_id = self.purchase_vendor_bill_id.purchase_order_id or self.purchase_id
|
||||
if purchase_order_id and self.l10n_in_company_country_code == 'IN':
|
||||
if purchase_order_id and purchase_order_id.country_code == 'IN':
|
||||
journal_id = self.purchase_vendor_bill_id.purchase_order_id.l10n_in_journal_id or self.purchase_id.l10n_in_journal_id
|
||||
if journal_id:
|
||||
self.journal_id = journal_id
|
||||
|
||||
@@ -19,11 +19,10 @@ class PurchaseOrder(models.Model):
|
||||
('special_economic_zone', 'Special Economic Zone'),
|
||||
('deemed_export', 'Deemed Export')
|
||||
], string="GST Treatment", states=Purchase.READONLY_STATES, compute="_compute_l10n_in_gst_treatment", store=True)
|
||||
l10n_in_company_country_code = fields.Char(related='company_id.account_fiscal_country_id.code', string="Country code")
|
||||
|
||||
@api.onchange('company_id')
|
||||
def l10n_in_onchange_company_id(self):
|
||||
if self.l10n_in_company_country_code == 'IN':
|
||||
if self.country_code == 'IN':
|
||||
domain = [('company_id', '=', self.company_id.id), ('type', '=', 'purchase')]
|
||||
journal = self.env['account.journal'].search(domain, limit=1)
|
||||
if journal:
|
||||
@@ -34,7 +33,7 @@ class PurchaseOrder(models.Model):
|
||||
for order in self:
|
||||
# set default value as False so CacheMiss error never occurs for this field.
|
||||
order.l10n_in_gst_treatment = False
|
||||
if order.l10n_in_company_country_code == 'IN':
|
||||
if order.country_code == 'IN':
|
||||
l10n_in_gst_treatment = order.partner_id.l10n_in_gst_treatment
|
||||
if not l10n_in_gst_treatment and order.partner_id.country_id and order.partner_id.country_id.code != 'IN':
|
||||
l10n_in_gst_treatment = 'overseas'
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
<field name="inherit_id" ref="purchase.purchase_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="l10n_in_company_country_code" invisible="1"/>
|
||||
<field name="l10n_in_gst_treatment" attrs="{'invisible': [('l10n_in_company_country_code', '!=', 'IN')], 'required': [('l10n_in_company_country_code', '=', 'IN')]}"/>
|
||||
<field name="country_code" invisible="1"/>
|
||||
<field name="l10n_in_gst_treatment" attrs="{'invisible': [('country_code', '!=', 'IN')], 'required': [('country_code', '=', 'IN')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//group[@name='other_info']//field[@name='user_id']" position="after">
|
||||
<field name="l10n_in_journal_id" options="{'no_create': True}" domain="[('company_id', '=', company_id), ('type', '=', 'purchase')]" attrs="{'invisible': [('l10n_in_company_country_code', '!=', 'IN')]}"/>
|
||||
<field name="l10n_in_journal_id" options="{'no_create': True}" domain="[('company_id', '=', company_id), ('type', '=', 'purchase')]" attrs="{'invisible': [('country_code', '!=', 'IN')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -19,14 +19,13 @@ class SaleOrder(models.Model):
|
||||
('special_economic_zone', 'Special Economic Zone'),
|
||||
('deemed_export', 'Deemed Export'),
|
||||
], string="GST Treatment", readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, compute="_compute_l10n_in_gst_treatment", store=True)
|
||||
l10n_in_company_country_code = fields.Char(related='company_id.account_fiscal_country_id.code', string="Country code")
|
||||
|
||||
@api.depends('partner_id')
|
||||
def _compute_l10n_in_gst_treatment(self):
|
||||
for order in self:
|
||||
# set default value as False so CacheMiss error never occurs for this field.
|
||||
order.l10n_in_gst_treatment = False
|
||||
if order.l10n_in_company_country_code == 'IN':
|
||||
if order.country_code == 'IN':
|
||||
l10n_in_gst_treatment = order.partner_id.l10n_in_gst_treatment
|
||||
if not l10n_in_gst_treatment and order.partner_id.country_id and order.partner_id.country_id.code != 'IN':
|
||||
l10n_in_gst_treatment = 'overseas'
|
||||
@@ -39,7 +38,7 @@ class SaleOrder(models.Model):
|
||||
for order in self:
|
||||
# set default value as False so CacheMiss error never occurs for this field.
|
||||
order.l10n_in_journal_id = False
|
||||
if order.l10n_in_company_country_code == 'IN':
|
||||
if order.country_code == 'IN':
|
||||
domain = [('company_id', '=', order.company_id.id), ('type', '=', 'sale')]
|
||||
journal = self.env['account.journal'].search(domain, limit=1)
|
||||
if journal:
|
||||
@@ -48,7 +47,7 @@ class SaleOrder(models.Model):
|
||||
|
||||
def _prepare_invoice(self):
|
||||
invoice_vals = super(SaleOrder, self)._prepare_invoice()
|
||||
if self.l10n_in_company_country_code == 'IN':
|
||||
if self.country_code == 'IN':
|
||||
invoice_vals['l10n_in_reseller_partner_id'] = self.l10n_in_reseller_partner_id.id
|
||||
if self.l10n_in_journal_id:
|
||||
invoice_vals['journal_id'] = self.l10n_in_journal_id.id
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
<field name="inherit_id" ref="sale.view_order_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='partner_id']" position="after">
|
||||
<field name="l10n_in_company_country_code" invisible="1"/>
|
||||
<field name="country_code" invisible="1"/>
|
||||
<field name="l10n_in_reseller_partner_id" groups="l10n_in.group_l10n_in_reseller"
|
||||
attrs="{'invisible': [('l10n_in_company_country_code','!=', 'IN')]}"/>
|
||||
attrs="{'invisible': [('country_code','!=', 'IN')]}"/>
|
||||
<field name="l10n_in_gst_treatment"
|
||||
attrs="{'invisible':[('l10n_in_company_country_code','!=','IN')],'required':[('l10n_in_company_country_code','=','IN')]}"/>
|
||||
attrs="{'invisible':[('country_code','!=','IN')],'required':[('country_code','=','IN')]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//group[@name='sale_info']//field[@name='invoice_status']" position="after">
|
||||
<field name="l10n_in_journal_id" domain="[('company_id', '=', company_id), ('type','=','sale')]" options="{'no_create': True}" attrs="{'invisible': [('l10n_in_company_country_code','!=', 'IN')]}"/>
|
||||
<field name="l10n_in_journal_id" domain="[('company_id', '=', company_id), ('type','=','sale')]" options="{'no_create': True}" attrs="{'invisible': [('country_code','!=', 'IN')]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -11,7 +11,7 @@ class SaleAdvancePaymentInv(models.TransientModel):
|
||||
res = super()._prepare_invoice_values(order, name, amount, so_line)
|
||||
if order.l10n_in_journal_id:
|
||||
res['journal_id'] = order.l10n_in_journal_id.id
|
||||
if order.l10n_in_company_country_code == 'IN':
|
||||
if order.country_code == 'IN':
|
||||
res['l10n_in_gst_treatment'] = order.l10n_in_gst_treatment
|
||||
if order.l10n_in_reseller_partner_id:
|
||||
res['l10n_in_reseller_partner_id'] = order.l10n_in_reseller_partner_id
|
||||
|
||||
@@ -11,6 +11,6 @@ class SaleOrder(models.Model):
|
||||
def _compute_l10n_in_journal_id(self):
|
||||
super()._compute_l10n_in_journal_id()
|
||||
for order in self:
|
||||
if order.l10n_in_company_country_code == 'IN':
|
||||
if order.country_code == 'IN':
|
||||
if order.warehouse_id.l10n_in_sale_journal_id:
|
||||
order.l10n_in_journal_id = order.warehouse_id.l10n_in_sale_journal_id.id
|
||||
|
||||
@@ -136,6 +136,7 @@ class PurchaseOrder(models.Model):
|
||||
'res.users', string='Purchase Representative', index=True, tracking=True,
|
||||
default=lambda self: self.env.user, check_company=True)
|
||||
company_id = fields.Many2one('res.company', 'Company', required=True, index=True, states=READONLY_STATES, default=lambda self: self.env.company.id)
|
||||
country_code = fields.Char(related='company_id.account_fiscal_country_id.code', string="Country code")
|
||||
currency_rate = fields.Float("Currency Rate", compute='_compute_currency_rate', compute_sudo=True, store=True, readonly=True, help='Ratio between the purchase order currency and the company currency')
|
||||
|
||||
mail_reminder_confirmed = fields.Boolean("Reminder Confirmed", default=False, readonly=True, copy=False, help="True if the reminder email is confirmed by the vendor.")
|
||||
|
||||
@@ -260,6 +260,7 @@ class SaleOrder(models.Model):
|
||||
compute_sudo=True,
|
||||
help="Technical field to filter the available taxes depending on the fiscal country and fiscal position.")
|
||||
company_id = fields.Many2one('res.company', 'Company', required=True, index=True, default=lambda self: self.env.company)
|
||||
country_code = fields.Char(related='company_id.account_fiscal_country_id.code', string="Country code")
|
||||
team_id = fields.Many2one(
|
||||
'crm.team', 'Sales Team',
|
||||
ondelete="set null", tracking=True,
|
||||
|
||||
Reference in New Issue
Block a user