[IMP] l10n_in: cleanup the demo data

This commit involves reorganization of demo data in the Indian localization
modules.
Specifically:
- Removed demo data entries.
- Added new demo data entries for improved examples.

task id: 3614544

closes odoo/odoo#144951

Related: odoo/enterprise#52104
Signed-off-by: Josse Colpaert <jco@odoo.com>
This commit is contained in:
Khushi Vakil
2023-12-22 10:36:23 +00:00
parent 98e9ab299b
commit fdfe918eec
16 changed files with 659 additions and 239 deletions
+1
View File
@@ -2,3 +2,4 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import models
from . import demo
-2
View File
@@ -47,9 +47,7 @@ Sheet, now only Vertical format has been permitted Which is Supported By Odoo.
],
'demo': [
'demo/demo_company.xml',
'demo/res_partner_demo.xml',
'demo/product_demo.xml',
'demo/account_invoice_demo.xml',
],
'license': 'LGPL-3',
}
+3
View File
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import account_demo
+612
View File
@@ -0,0 +1,612 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
import time
from datetime import datetime, timedelta
from odoo import api, models, Command
from odoo.exceptions import UserError, ValidationError
from odoo.tools.misc import file_open
_logger = logging.getLogger(__name__)
class AccountChartTemplate(models.AbstractModel):
_inherit = "account.chart.template"
@api.model
def _get_demo_data(self, company=False):
demo_data = {}
if company.account_fiscal_country_id.code == "IN":
if company.state_id:
demo_data = {
'res.partner.category': self._get_demo_data_res_partner_category(company),
'res.partner': self._get_demo_data_partner(company),
'account.move': self._get_demo_data_move(company),
'res.config.settings': self._get_demo_data_config_settings(company),
'ir.attachment': self._get_demo_data_attachment(company),
'mail.message': self._get_demo_data_mail_message(company),
}
else:
_logger.error('Error while loading Indian-Accounting demo data in the company "%s".State is not set in the company.', company.name)
else:
demo_data = super()._get_demo_data(company)
return demo_data
@api.model
def _get_demo_data_config_settings(self, company=False):
return{
'sales_credit_limit':{
'account_use_credit_limit': True,
'account_default_credit_limit': '10000'
}
}
@api.model
def _get_demo_data_res_partner_category(self, company=False):
return{
'res_partner_category_registered': {
'name': 'Registered',
'color': 2,
},
'res_partner_category_unregistered': {
'name': 'Unregistered',
'color': 3,
},
}
@api.model
def _get_demo_data_partner(self, company=False):
cid = company.id or self.env.company.id
intra_state_id = company.state_id
inter_state_id = self.env['res.country.state'].search([
('id', 'not in', intra_state_id.ids),
('country_id', '=', intra_state_id.country_id.id)
], order='name DESC', limit=1)
default_partner_dict = {'city': 'City', 'zip': '000000', 'country_id': 'base.in', 'is_company': True}
return{
'res_partner_registered_customer': {
**default_partner_dict,
'name': 'B2B Customer Inter State',
'category_id': 'res_partner_category_registered',
'l10n_in_gst_treatment': 'regular',
'street': '201, Second Floor, IT Tower 4',
'street2': 'InfoCity Gate - 1, Infocity',
'state_id': inter_state_id.id,
'company_id': cid,
'vat': '%sAABCT1332L2ZD'%(inter_state_id.l10n_in_tin),
},
'res_partner_registered_customer_intra_state': {
**default_partner_dict,
'name': 'B2B Customer Intra State',
'category_id': 'res_partner_category_registered',
'l10n_in_gst_treatment': 'regular',
'street': 'floor-1, Maddikunta-Ankanpally Village',
'street2': 'Post box No 2, NH-65',
'state_id': intra_state_id.id,
'company_id': cid,
'vat': '%sAAACM4154G1ZO'%(intra_state_id.l10n_in_tin),
},
'res_partner_unregistered_customer':{
**default_partner_dict,
'name': 'B2C Customer Inter State',
'category_id': 'res_partner_category_unregistered',
'l10n_in_gst_treatment': 'unregistered',
'street': 'B105, yogeshwar Tower',
'state_id': inter_state_id.id,
'company_id': cid,
},
'res_partner_unregistered_customer_intra_state':{
**default_partner_dict,
'name': 'B2C Customer Intra State',
'category_id': 'res_partner_category_unregistered',
'l10n_in_gst_treatment': 'unregistered',
'street': '80, Sarojini Devi Road',
'state_id': intra_state_id.id,
'company_id': cid,
},
'res_partner_registered_supplier_1': {
**default_partner_dict,
'name': 'Supplier',
'category_id': 'res_partner_category_registered',
'l10n_in_gst_treatment': 'regular',
'street': '19, Ground Floor',
'street2': 'Survey Road,Vadipatti',
'state_id': inter_state_id.id,
'company_id': cid,
'vat': '%sAACCT6304M1DB'%(inter_state_id.l10n_in_tin),
},
'res_partner_registered_supplier_2': {
**default_partner_dict,
'name': 'Odoo In Private Limited',
'category_id': 'res_partner_category_registered',
'l10n_in_gst_treatment': 'regular',
'street': '201, Second Floor, IT Tower 4',
'street2': 'InfoCity Gate - 1, Infocity',
'state_id': inter_state_id.id,
'company_id': cid,
'vat': '%sAACCT6304M1ZB'%(inter_state_id.l10n_in_tin),
},
'res_partner_overseas': {
'name': 'Supplier Overseas',
'l10n_in_gst_treatment': 'overseas',
'street': '142 Street, Rigas building',
'street2': 'Survey Road,',
'city': 'City',
'zip': '000000',
'state_id': 'base.state_us_5',
'country_id': 'base.us',
'is_company': True,
'company_id': cid,
},
}
@api.model
def _get_demo_data_move(self, company=False):
cid = company.id or self.env.company.id
def _get_tax_by_id(tax_id):
tax = self.env.ref('account.%s_%s'%((cid), (tax_id)))
return tax.id
if company.account_fiscal_country_id.code == "IN":
sale_journal = self.env['account.journal'].search(
domain=[
*self.env['account.journal']._check_company_domain(cid),
('type', '=', 'sale'),
], limit=1)
return {
# Demo of B2B (business-to-business) Taxable supplies made to other registered person.
'demo_invoice_b2b_1': {
'move_type': 'out_invoice',
'partner_id': 'res_partner_registered_customer',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'l10n_in_gst_treatment': 'regular',
'journal_id': sale_journal.id,
'invoice_line_ids': [
Command.create({
'product_id': 'product.product_product_8',
'quantity': 2,
'price_unit': 40000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_sale_28')])],
}),
Command.create({
'product_id': 'product.product_product_9',
'quantity': 3,
'price_unit': 400.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_sale_28'), _get_tax_by_id('cess_5_plus_1591_sale')])],
}),
Command.create({
'product_id': 'product.product_product_10',
'quantity': 4,
'price_unit': 300.0,
'tax_ids':[Command.set([_get_tax_by_id('igst_sale_18')])],
}),
],
},
'demo_invoice_b2b_2': {
'move_type': 'out_invoice',
'partner_id': 'res_partner_registered_customer_intra_state',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'l10n_in_gst_treatment': 'regular',
'journal_id': sale_journal.id,
'invoice_line_ids': [
Command.create({
'product_id': 'product.product_product_9',
'quantity': 2,
'price_unit': 4000.0,
'tax_ids': [Command.set([_get_tax_by_id('sgst_sale_5')])],
}),
Command.create({
'product_id': 'product.product_product_10',
'quantity': 3,
'price_unit': 300.0,
'tax_ids': [Command.set([_get_tax_by_id('sgst_sale_5')])],
}),
],
},
'demo_bill_b2b_1': {
'ref': 'INV/001',
'move_type': 'in_invoice',
'partner_id': 'res_partner_registered_supplier_2',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'invoice_line_ids': [
Command.create({
'product_id': 'product.consu_delivery_01',
'quantity': 1,
'price_unit': 1000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_purchase_18')])],
}),
Command.create({
'product_id': 'product.consu_delivery_03',
'quantity': 1,
'price_unit': 2000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_purchase_18')])],
}),
]
},
'demo_bill_b2b_2': {
'ref': 'INV/002',
'move_type': 'in_invoice',
'partner_id': 'res_partner_registered_supplier_2',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'invoice_line_ids': [
Command.create({
'product_id': 'product.consu_delivery_01',
'quantity': 4,
'price_unit': 1000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_purchase_18')])],
}),
Command.create({
'product_id': 'product.consu_delivery_03',
'quantity': 3,
'price_unit': 2000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_purchase_18')])],
}),
]
},
'demo_bill_b2b_3': {
'ref': 'INV/003',
'move_type': 'in_invoice',
'partner_id': 'res_partner_registered_supplier_1',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'invoice_line_ids': [
Command.create({
'product_id': 'product.consu_delivery_01',
'quantity': 2,
'price_unit': 1000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_purchase_18')])],
}),
Command.create({
'product_id': 'product.consu_delivery_03',
'quantity': 3,
'price_unit': 2000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_purchase_18')])],
}),
]
},
'demo_invoice_to_extract': {
'move_type': 'in_invoice',
'message_main_attachment_id': 'ir_attachment_in_invoice_1',
},
'demo_invoice_service': {
'ref': 'MYS-91021146',
'move_type': 'in_invoice',
'partner_id': 'res_partner_registered_supplier_2',
'invoice_user_id': False,
'invoice_date': datetime.now(),
'invoice_line_ids': [
Command.create({
'name': 'Integrated Managed Infrastructure Service',
'quantity': 1,
'price_unit': 69132.78,
'tax_ids': [Command.set([_get_tax_by_id('igst_purchase_18')])],
}),
],
'message_main_attachment_id': 'ir_attachment_in_invoice_2',
},
# Demo of IMP(Import) of supplies.
'demo_bill_imp': {
'ref': 'BOE/123',
'move_type': 'in_invoice',
'partner_id': 'res_partner_overseas',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'invoice_line_ids': [
Command.create({
'product_id': 'product.product_product_4',
'quantity': 30,
'price_unit': 9000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_purchase_18')])],
}),
]
},
# Demo of cdnr(Credit/ Debit Note for registered business). Create credit note for demo b2b bill.
'demo_bill_cdnr_1': {
'ref': 'CR/001',
'move_type': 'in_refund',
'partner_id': 'res_partner_registered_supplier_2',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now() - timedelta(days=1),
'l10n_in_gst_treatment': 'regular',
'invoice_line_ids': [
Command.create({
'product_id': 'product.consu_delivery_01',
'quantity': 1,
'price_unit': 1000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_purchase_18')])],
}),
Command.create({
'product_id': 'product.consu_delivery_03',
'quantity': 1,
'price_unit': 2000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_purchase_18')])],
}),
]
},
'demo_bill_cdnr_2': {
'ref': '000072',
'move_type': 'in_refund',
'partner_id': 'res_partner_registered_supplier_1',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'l10n_in_gst_treatment': 'regular',
'invoice_line_ids': [
Command.create({
'product_id': 'product.consu_delivery_01',
'quantity': 1,
'price_unit': 1000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_purchase_18')])],
}),
]
},
# Demo of B2CS (business to consumer small) Taxable supplies made to other unregistered Person and below INR 2.5 lakhs invoice value.
'demo_invoice_b2cs': {
'move_type': 'out_invoice',
'partner_id': 'res_partner_unregistered_customer_intra_state',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'l10n_in_gst_treatment': 'consumer',
'journal_id': sale_journal.id,
'invoice_line_ids': [
Command.create({
'product_id': 'product.product_product_16',
'quantity': 1,
'price_unit': 1500.0,
'tax_ids': [Command.set([_get_tax_by_id('sgst_sale_18')])],
}),
Command.create({
'product_id': 'product.product_product_20',
'quantity': 1,
'price_unit': 2300.0,
'tax_ids': [Command.set([_get_tax_by_id('sgst_sale_18')])],
}),
Command.create({
'product_id': 'product.product_product_22',
'quantity': 1,
'price_unit': 2600.0,
'tax_ids': [Command.set([_get_tax_by_id('sgst_sale_18')])],
}),
Command.create({
'product_id': 'product.product_product_24',
'quantity': 2,
'price_unit': 1655.0,
'tax_ids': [Command.set([_get_tax_by_id('sgst_sale_5')])],
}),
]
},
# Demo of B2CL (business to consumer - Large) Taxable supplies made to other unregistered Person and invoice value is more than INR 2.5 lakhs.
'demo_invoice_b2cl': {
'move_type': 'out_invoice',
'partner_id': 'res_partner_unregistered_customer',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'l10n_in_gst_treatment': 'consumer',
'journal_id': sale_journal.id,
'invoice_line_ids': [
Command.create({
'product_id': 'product.consu_delivery_01',
'quantity': 3,
'price_unit': 90000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_sale_18')])],
}),
]
},
# Demo of EXP(Export) supplies including supplies to SEZ/SEZ Developer or deemed exports.
'demo_invoice_exp': {
'move_type': 'out_invoice',
'partner_id': 'base.res_partner_3',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'l10n_in_gst_treatment': 'overseas',
'l10n_in_shipping_bill_number': '999704',
'l10n_in_shipping_bill_date': time.strftime('%Y-%m-02'),
'l10n_in_shipping_port_code_id': 'l10n_in.port_code_inixy1',
'journal_id': sale_journal.id,
'invoice_line_ids': [
Command.create({
'product_id': 'product.product_product_4',
'quantity': 30,
'price_unit': 8000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_sale_18')])],
}),
]
},
# Demo of exempt(Nil Rated, Exempted and Non GST supplies). Set Nill rated and Exempted tax in line.
'demo_invoice_nill': {
'move_type': 'out_invoice',
'partner_id': 'res_partner_registered_customer',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'l10n_in_gst_treatment': 'regular',
'journal_id': sale_journal.id,
'invoice_line_ids': [
Command.create({
'product_id': 'product.product_product_1',
'quantity': 2,
'price_unit': 25000.0,
'tax_ids': [Command.set([_get_tax_by_id('exempt_sale')])],
}),
Command.create({
'product_id': 'product.product_product_5',
'quantity': 1,
'price_unit': 400.0,
'tax_ids': [Command.set([_get_tax_by_id('nil_rated_sale')])],
}),
]
},
# Demo of cdnr(Credit/ Debit Note for registered person). Create credit note for demo b2b invoice.
'demo_invoice_cdnr_1': {
'move_type': 'out_refund',
'partner_id': 'res_partner_registered_customer',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'l10n_in_gst_treatment': 'regular',
'reversed_entry_id': 'demo_invoice_b2b_1',
'journal_id': sale_journal.id,
'invoice_line_ids': [
Command.create({
'product_id': 'product.product_product_8',
'quantity': 2,
'price_unit': 40000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_sale_28')])],
}),
Command.create({
'product_id': 'product.product_product_9',
'quantity': 3,
'price_unit': 400.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_sale_28'), _get_tax_by_id('cess_5_plus_1591_sale')])],
}),
Command.create({
'product_id': 'product.product_product_10',
'quantity': 4,
'price_unit': 300.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_sale_18')])],
}),
]
},
'demo_invoice_cdnr_2': {
'move_type': 'out_refund',
'partner_id': 'res_partner_registered_customer',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'l10n_in_gst_treatment': 'regular',
'journal_id': sale_journal.id,
'invoice_line_ids': [
Command.create({
'product_id': 'product.consu_delivery_01',
'quantity': 1,
'price_unit': 1000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_sale_18')])],
}),
Command.create({
'product_id': 'product.consu_delivery_03',
'quantity': 1,
'price_unit': 2000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_sale_18')])],
}),
]
},
# Demo of cdnr(Credit/ Debit Note for unregistered person). Create credit note for demo b2cl invoice.
'demo_invoice_cdnur': {
'move_type': 'out_refund',
'partner_id': 'res_partner_unregistered_customer',
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': datetime.now(),
'l10n_in_gst_treatment': 'consumer',
'reversed_entry_id': 'demo_invoice_b2cl',
'journal_id': sale_journal.id,
'invoice_line_ids': [
Command.create({
'product_id': 'product.consu_delivery_01',
'quantity': 3,
'price_unit': 90000.0,
'tax_ids': [Command.set([_get_tax_by_id('igst_sale_18')])],
}),
]
},
}
else:
return super()._get_demo_data_move(company)
@api.model
def _get_demo_data_attachment(self, company=False):
if company.account_fiscal_country_id.code == "IN":
return{
'ir_attachment_in_invoice_1': {
'type': 'binary',
'name': 'in_invoice_demo_1.pdf',
'res_model': 'account.move',
'res_id': 'demo_invoice_to_extract',
'raw': file_open(
'l10n_in/static/demo/in_invoice_demo_1.pdf', 'rb'
).read()
},
'ir_attachment_in_invoice_2': {
'type': 'binary',
'name': 'in_invoice_demo_2.pdf',
'res_model': 'account.move',
'res_id': 'demo_invoice_service',
'raw': file_open(
'l10n_in/static/demo/in_invoice_demo_2.pdf', 'rb'
).read()
}
}
else:
return super()._get_demo_data_attachment(company)
@api.model
def _get_demo_data_mail_message(self, company=False):
if company.account_fiscal_country_id.code == "IN":
return {
'mail_message_in_invoice_1': {
'model': 'account.move',
'res_id': 'demo_invoice_to_extract',
'body': 'Vendor Bill attachment',
'message_type': 'comment',
'author_id': 'base.partner_demo',
'attachment_ids': [Command.set([
'ir_attachment_in_invoice_1',
])]
},
'mail_message_in_invoice_2': {
'model': 'account.move',
'res_id': 'demo_invoice_service',
'body': 'Vendor Bill attachment',
'message_type': 'comment',
'author_id': 'base.partner_demo',
'attachment_ids': [Command.set([
'ir_attachment_in_invoice_2',
])]
},
}
else:
return super()._get_demo_data_mail_message(company)
def _post_load_demo_data(self, company=False):
if company.account_fiscal_country_id.code == "IN":
if company.state_id:
invoices = (
self.ref('demo_invoice_b2b_1')
+ self.ref('demo_invoice_b2b_2')
+ self.ref('demo_invoice_b2cs')
+ self.ref('demo_invoice_b2cl')
+ self.ref('demo_invoice_exp')
+ self.ref('demo_invoice_nill')
+ self.ref('demo_invoice_cdnr_1')
+ self.ref('demo_invoice_cdnr_2')
+ self.ref('demo_invoice_cdnur')
+ self.ref('demo_bill_b2b_1')
+ self.ref('demo_bill_b2b_2')
+ self.ref('demo_bill_b2b_3')
+ self.ref('demo_bill_imp')
+ self.ref('demo_bill_cdnr_1')
+ self.ref('demo_bill_cdnr_2')
+ self.ref('demo_invoice_service')
)
for move in invoices:
try:
move.action_post()
except (UserError, ValidationError):
_logger.exception('Error while posting demo data')
else:
return super()._post_load_demo_data(company)
@@ -1,56 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<record id="demo_invoice_b2b_intra_state" model="account.move">
<field name="move_type">out_invoice</field>
<field name="partner_id" ref="l10n_in.res_partner_registered_customer_intra_state"/>
<field name="l10n_in_reseller_partner_id" ref="l10n_in.res_partner_reseller"/>
<field name="invoice_user_id" ref="base.user_demo"/>
<field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/>
<field name="invoice_date" eval="time.strftime('%Y-%m')+'-01'"/>
<field name="l10n_in_gst_treatment">regular</field>
<field name="journal_id" model="account.journal"
eval="obj().search([
('type', '=', 'sale'),
('company_id', '=', ref('l10n_in.demo_company_in'))], limit=1).id"/>
<field name="invoice_line_ids" model="account.move.line" eval="[
(0, 0, {
'product_id': ref('product.product_product_8'),
'quantity': 2,
'price_unit': 40000.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('company_id', '=', ref('l10n_in.demo_company_in')),
('type_tax_use', '=', 'sale'),
('amount','=', 28),
('tax_group_id', '=', ref('account.{}_gst_group'.format(ref('l10n_in.demo_company_in'))))], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_9'),
'quantity': 3,
'price_unit': 400.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('company_id', '=', ref('l10n_in.demo_company_in')),
('type_tax_use', '=', 'sale'),
('amount','=', 18),
('tax_group_id', '=', ref('account.{}_gst_group'.format(ref('l10n_in.demo_company_in'))))], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_10'),
'quantity': 4,
'price_unit': 300.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('company_id', '=', ref('l10n_in.demo_company_in')),
('type_tax_use', '=', 'sale'),
'|',
'&amp;',
('amount', '=', 18),
('tax_group_id', '=', ref('account.{}_gst_group'.format(ref('l10n_in.demo_company_in')))),
'&amp;',
('tax_group_id', '=', ref('account.{}_cess_group'.format(ref('l10n_in.demo_company_in')))),
('children_tax_ids.amount','=', 5)
], limit=2).ids)]
}),
]"/>
</record>
</odoo>
+1 -1
View File
@@ -2,7 +2,7 @@
<odoo>
<record id="partner_demo_company_in" model="res.partner">
<field name="name">IN Company</field>
<field name="vat">36AABCT1332L011</field>
<field name="vat">24DUMMY1234AAZA</field>
<field name="street">Block no. 401</field>
<field name="street2">Street 2</field>
<field name="city">Hyderabad</field>
-43
View File
@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<record id="res_partner_category_registered" model="res.partner.category">
<field name="name">Registered</field>
<field name="color" eval="2"/>
</record>
<record id="res_partner_category_unregistered" model="res.partner.category">
<field name="name">Unregistered</field>
<field name="color" eval="3"/>
</record>
<record id="res_partner_category_reseller" model="res.partner.category">
<field name="name">Reseller</field>
<field name="color" eval="12"/>
</record>
<record id="res_partner_registered_customer_intra_state" model="res.partner">
<field name="name">Registered Customer Intra State</field>
<field eval="[(6, 0, [ref('l10n_in.res_partner_category_registered')])]" name="category_id"/>
<field name="is_company">1</field>
<field name="l10n_in_gst_treatment">regular</field>
<field name="street">floor-1, Maddikunta-Ankanpally Village</field>
<field name="street2">Post box No 2, NH-65</field>
<field name="city">Sangareddy</field>
<field name="zip">500002</field>
<field name="state_id" ref="base.state_in_ts"/>
<field name="country_id" ref="base.in"/>
<field name="vat">36AAACM4154G1ZO</field>
</record>
<!-- reseller partner -->
<record id="res_partner_reseller" model="res.partner">
<field name="name">Reseller(E-Commerce)</field>
<field eval="[(6, 0, [ref('l10n_in.res_partner_category_reseller'),
ref('l10n_in.res_partner_category_registered')])]" name="category_id"/>
<field name="street">4/001 Ground Floor, 16th Main Rd,</field>
<field name="l10n_in_gst_treatment">regular</field>
<field name="city">Bengaluru</field>
<field name="zip">560001</field>
<field name="state_id" ref="base.state_in_ka"/>
<field name="country_id" ref="base.in"/>
<field name="vat">29AJIPA1572E1ZR</field>
</record>
</odoo>
Binary file not shown.
Binary file not shown.
@@ -29,8 +29,6 @@ Step 4: Repeat steps 1,2,3 for all GSTIN you have in odoo. If you have a multi-c
],
"demo": [
"demo/demo_company.xml",
"demo/res_partner_demo.xml",
"demo/account_invoice_demo.xml",
],
"installable": True,
# not auto_install because the company can be related to the service industry
+1 -2
View File
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import chart_template
from . import account_demo
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import logging
from odoo import api, models
_logger = logging.getLogger(__name__)
class AccountChartTemplate(models.AbstractModel):
_inherit = "account.chart.template"
def _post_load_demo_data(self, company=False):
if company and company.account_fiscal_country_id.code == 'IN':
self._update_l10n_in_demo_data(company)
return super()._post_load_demo_data(company)
@api.model
def _update_l10n_in_demo_data(self, company=False):
indian_companies = company or self.env['res.company'].search([('account_fiscal_country_id.code', '=', 'IN')])
for indian_company in indian_companies:
if indian_company.state_id:
invoices = [
'demo_invoice_b2b_1',
'demo_invoice_b2b_2',
'demo_invoice_b2cs',
'demo_invoice_b2cl',
'demo_invoice_nill',
]
for xml_id in invoices:
self.ref("account.%s_%s"%(indian_company.id, xml_id)).write({
'l10n_in_type_id': self.env.ref("l10n_in_edi_ewaybill.type_tax_invoice_sub_type_supply"),
'l10n_in_distance': 20,
'l10n_in_mode': '1',
'l10n_in_vehicle_no': 'GJ11OD1234',
'l10n_in_vehicle_type': 'R',
})
else:
_logger.error('Error while loading Indian-Ewaybill demo data in the company "%s".State is not set in the company.', indian_company.name)
@@ -1,66 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<function model="account.journal" name="write">
<value model="account.journal"
eval="obj().search([
('type', '=', 'sale'),
('company_id', '=', ref('l10n_in_edi_ewaybill.demo_company_in_ewaybill'))], limit=1).ids"/>
<value eval="{'edi_format_ids': [(6,0,[ref('edi_in_ewaybill_json_1_03')])]}"/>
</function>
<!-- Demo of B2B (business-to-business) Taxable supplies made to other registered person.-->
<record id="demo_invoice_b2b_ewaybill" model="account.move">
<field name="move_type">out_invoice</field>
<field name="partner_id" ref="res_partner_registered_customer_ewaybill"/>
<field name="invoice_user_id" ref="base.user_demo"/>
<field name="invoice_payment_term_id" ref="account.account_payment_term_end_following_month"/>
<field name="invoice_date" eval="time.strftime('%Y-%m')+'-01'"/>
<field name="l10n_in_gst_treatment">regular</field>
<field name="l10n_in_type_id" ref="type_tax_invoice_sub_type_supply"/>
<field name="l10n_in_distance">20</field>
<field name="l10n_in_mode">1</field>
<field name="l10n_in_vehicle_no">GJ11OD1234</field>
<field name="l10n_in_vehicle_type">R</field>
<field name="journal_id" model="account.journal"
eval="obj().search([
('type', '=', 'sale'),
('company_id', '=', ref('l10n_in_edi_ewaybill.demo_company_in_ewaybill'))], limit=1).id"/>
<field name="invoice_line_ids" model="account.move.line" eval="[
(0, 0, {
'product_id': ref('product.product_product_8'),
'quantity': 2,
'price_unit': 40000.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('company_id', '=', ref('l10n_in_edi_ewaybill.demo_company_in_ewaybill')),
('type_tax_use', '=', 'sale'),
('amount','=', 28),
('tax_group_id', '=', ref('account.%s_igst_group' % ref('l10n_in_edi_ewaybill.demo_company_in_ewaybill')))], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_9'),
'quantity': 3,
'price_unit': 400.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('company_id', '=', ref('l10n_in_edi_ewaybill.demo_company_in_ewaybill')),
('type_tax_use', '=', 'sale'),
('amount','=', 18),
('tax_group_id', '=', ref('account.%s_igst_group' % ref('l10n_in_edi_ewaybill.demo_company_in_ewaybill')))], limit=1).ids)]
}),
(0, 0, {
'product_id': ref('product.product_product_10'),
'quantity': 4,
'price_unit': 300.0,
'tax_ids': [(6, 0, obj().tax_ids.search([
('company_id', '=', ref('l10n_in_edi_ewaybill.demo_company_in_ewaybill')),
('type_tax_use', '=', 'sale'),
'|',
'&amp;',
('amount', '=', 18),
('tax_group_id', '=', ref('account.%s_igst_group' % ref('l10n_in_edi_ewaybill.demo_company_in_ewaybill'))),
'&amp;',
('tax_group_id', '=', ref('account.%s_cess_group' % ref('l10n_in_edi_ewaybill.demo_company_in_ewaybill'))),
('children_tax_ids.amount','=', 5)
], limit=2).ids)]
}),
]"/>
</record>
</odoo>
@@ -1,19 +0,0 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, api, Command
class AccountChartTemplate(models.AbstractModel):
_inherit = 'account.chart.template'
@api.model
def _get_demo_data(self, company=False):
company = company or self.env.company
"""We need to deactivate einvoice here, as we can not send e-invoice and e-waybill in the same demo company"""
if company == self.env.ref('l10n_in_edi_ewaybill.demo_company_in_ewaybill'):
sales_journals = self.env['account.journal'].search([
*self.env['account.journal']._check_company_domain(company),
('type', '=', 'sale'),
])
sales_journals.write({'edi_format_ids': [Command.unlink(self.env.ref('l10n_in_edi.edi_in_einvoice_json_1_03').id)]})
return super()._get_demo_data(company)
@@ -1,35 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="partner_demo_company_in_ewaybill" model="res.partner">
<field name="name">E-Waybill Company</field>
<field name="vat">05AAACH6188F1ZM</field>
<field name="street">46B 49B, RAIPUR</field>
<field name="street2">BHAGWANPUR, ROORKEE</field>
<field name="city">Haridwar</field>
<field name="country_id" ref="base.in"/>
<field name="state_id" ref="base.state_in_uk"/>
<field name="zip">247667</field>
<record id="l10n_in.demo_company_in" model="res.company">
<field name="l10n_in_edi_ewaybill_username">iap_odoo</field>
<field name="l10n_in_edi_ewaybill_password">odoo</field>
</record>
<record id="demo_company_in_ewaybill" model="res.company">
<field name="name">E-Waybill Company</field>
<field name="partner_id" ref="partner_demo_company_in_ewaybill"/>
<field name="l10n_in_edi_ewaybill_username">05AAACH6188F1ZM</field>
<field name="l10n_in_edi_ewaybill_password">abc123@@</field>
</record>
<function model="res.company" name="_onchange_country_id">
<value eval="[ref('demo_company_in_ewaybill')]"/>
</function>
<function model="res.users" name="write">
<value eval="[ref('base.user_root'), ref('base.user_admin'), ref('base.user_demo')]"/>
<value eval="{'company_ids': [(4, ref('demo_company_in_ewaybill'))]}"/>
</function>
<function model="account.chart.template" name="try_loading">
<value eval="[]"/>
<value>in</value>
<value model="res.company" eval="obj().env.ref('l10n_in_edi_ewaybill.demo_company_in_ewaybill')"/>
</function>
<function model="account.chart.template" name="_update_l10n_in_demo_data"/>
</odoo>
@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="res_partner_registered_customer_ewaybill" model="res.partner">
<field name="name">Registered Customer (E-Waybill)</field>
<field eval="[(6, 0, [ref('l10n_in.res_partner_category_registered')])]" name="category_id"/>
<field name="is_company">1</field>
<field name="l10n_in_gst_treatment">regular</field>
<field name="street">19, Ground Floor</field>
<field name="street2">Survey Road</field>
<field name="city">Dehradun</field>
<field name="zip">248001</field>
<field name="state_id" ref="base.state_in_uk"/>
<field name="country_id" ref="base.in"/>
<field name="vat">05AAACH6605F1Z0</field>
</record>
</odoo>