mirror of
https://github.com/bringout/oca-ocb-l10n_americas.git
synced 2026-04-27 19:32:00 +02:00
19.0 vanilla
This commit is contained in:
parent
89c6e82fe7
commit
1b82c20a58
572 changed files with 43570 additions and 53303 deletions
|
|
@ -4,65 +4,63 @@ from datetime import datetime, timedelta
|
|||
from odoo import api, Command, models
|
||||
|
||||
|
||||
class AccountChartTemplate(models.Model):
|
||||
class AccountChartTemplate(models.AbstractModel):
|
||||
_inherit = "account.chart.template"
|
||||
|
||||
@api.model
|
||||
def _get_demo_data_move(self):
|
||||
cid = self.env.company.id
|
||||
|
||||
def _get_demo_data_move(self, company=False):
|
||||
def _get_tax_by_code(code, type_tax='sale'):
|
||||
taxes = self.env['account.tax'].search([
|
||||
('company_id', '=', cid), ('type_tax_use', '=', type_tax), ('l10n_pe_edi_tax_code', '=', code)], limit=1)
|
||||
('type_tax_use', '=', type_tax), ('l10n_pe_edi_tax_code', '=', code)], limit=1)
|
||||
return [Command.set(taxes.ids)]
|
||||
|
||||
model, data = super()._get_demo_data_move()
|
||||
move_data = super()._get_demo_data_move(company)
|
||||
ref = self.env.ref
|
||||
last_month_date = datetime.strptime(data[f'{cid}_demo_invoice_1']['invoice_date'], '%Y-%m-%d') - timedelta(days=1)
|
||||
if self.env.company.account_fiscal_country_id.code == "PE":
|
||||
data[f'{cid}_demo_invoice_1']['invoice_date'] = last_month_date
|
||||
data[f'{cid}_demo_invoice_1']['l10n_latam_document_number'] = 'FFF-0000001'
|
||||
data[f'{cid}_demo_invoice_1']['invoice_line_ids'] = [
|
||||
last_month_date = datetime.strptime(move_data[self.company_xmlid('demo_invoice_1')]['invoice_date'], '%Y-%m-%d') - timedelta(days=1)
|
||||
if company.account_fiscal_country_id.code == "PE":
|
||||
move_data[self.company_xmlid('demo_invoice_1')]['invoice_date'] = last_month_date
|
||||
move_data[self.company_xmlid('demo_invoice_1')]['l10n_latam_document_number'] = 'FFF-0000001'
|
||||
move_data[self.company_xmlid('demo_invoice_1')]['invoice_line_ids'] = [
|
||||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 25000.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('9997')}),
|
||||
]
|
||||
data[f'{cid}_demo_invoice_2']['invoice_date'] = last_month_date
|
||||
data[f'{cid}_demo_invoice_2']['l10n_latam_document_number'] = 'FFF-0000002'
|
||||
data[f'{cid}_demo_invoice_2']['invoice_line_ids'] = [
|
||||
move_data[self.company_xmlid('demo_invoice_2')]['invoice_date'] = last_month_date
|
||||
move_data[self.company_xmlid('demo_invoice_2')]['l10n_latam_document_number'] = 'FFF-0000002'
|
||||
move_data[self.company_xmlid('demo_invoice_2')]['invoice_line_ids'] = [
|
||||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 12500.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('1000')}),
|
||||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 1000.0, 'tax_ids': _get_tax_by_code('9997')}),
|
||||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 1500.0, 'tax_ids': _get_tax_by_code('9998')}),
|
||||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 12500.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('1000')}),
|
||||
]
|
||||
data[f'{cid}_demo_invoice_3']['invoice_date'] = last_month_date
|
||||
data[f'{cid}_demo_invoice_3']['l10n_latam_document_type_id'] = ref('l10n_pe.document_type08').id,
|
||||
data[f'{cid}_demo_invoice_3']['l10n_latam_document_number'] = 'NDI-0000001'
|
||||
data[f'{cid}_demo_invoice_3']['invoice_line_ids'] = [
|
||||
move_data[self.company_xmlid('demo_invoice_3')]['invoice_date'] = last_month_date
|
||||
move_data[self.company_xmlid('demo_invoice_3')]['l10n_latam_document_type_id'] = ref('l10n_pe.document_type08').id
|
||||
move_data[self.company_xmlid('demo_invoice_3')]['l10n_latam_document_number'] = 'NDI-0000001'
|
||||
move_data[self.company_xmlid('demo_invoice_3')]['invoice_line_ids'] = [
|
||||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 12500.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('1000')}),
|
||||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 1000.0, 'tax_ids': _get_tax_by_code('9997')}),
|
||||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 1500.0, 'tax_ids': _get_tax_by_code('9998')}),
|
||||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 12500.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('1000')}),
|
||||
]
|
||||
data[f'{cid}_demo_invoice_followup']['move_type'] = 'in_invoice'
|
||||
data[f'{cid}_demo_invoice_followup']['partner_id'] = ref('base.res_partner_2').id
|
||||
data[f'{cid}_demo_invoice_followup']['invoice_date'] = last_month_date
|
||||
data[f'{cid}_demo_invoice_followup']['l10n_latam_document_number'] = 'FFF-100001'
|
||||
data[f'{cid}_demo_invoice_followup']['invoice_line_ids'] = [
|
||||
move_data[self.company_xmlid('demo_invoice_followup')]['move_type'] = 'in_invoice'
|
||||
move_data[self.company_xmlid('demo_invoice_followup')]['partner_id'] = ref('base.res_partner_2').id
|
||||
move_data[self.company_xmlid('demo_invoice_followup')]['invoice_date'] = last_month_date
|
||||
move_data[self.company_xmlid('demo_invoice_followup')]['l10n_latam_document_number'] = 'FFF-100001'
|
||||
move_data[self.company_xmlid('demo_invoice_followup')]['invoice_line_ids'] = [
|
||||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 500.0}),
|
||||
]
|
||||
data[f'{cid}_demo_invoice_5']['partner_id'] = ref('base.res_partner_2').id
|
||||
data[f'{cid}_demo_invoice_5']['invoice_date'] = last_month_date
|
||||
data[f'{cid}_demo_invoice_5']['l10n_latam_document_number'] = 'FFF-100002'
|
||||
data[f'{cid}_demo_invoice_5']['invoice_line_ids'] = [
|
||||
move_data[self.company_xmlid('demo_invoice_5')]['partner_id'] = ref('base.res_partner_2').id
|
||||
move_data[self.company_xmlid('demo_invoice_5')]['invoice_date'] = last_month_date
|
||||
move_data[self.company_xmlid('demo_invoice_5')]['l10n_latam_document_number'] = 'FFF-100002'
|
||||
move_data[self.company_xmlid('demo_invoice_5')]['invoice_line_ids'] = [
|
||||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 500.0, 'tax_ids': _get_tax_by_code('1000', 'purchase')}),
|
||||
]
|
||||
igv_gyng_tax = self.env['account.tax'].search([('company_id', '=', cid), ('type_tax_use', '=', 'purchase'), ('tax_group_id.name', '=', 'IGV GyNG')], limit=1)
|
||||
data[f'{cid}_demo_invoice_equipment_purchase']['partner_id'] = ref('base.res_partner_2').id
|
||||
data[f'{cid}_demo_invoice_equipment_purchase']['invoice_date'] = last_month_date
|
||||
data[f'{cid}_demo_invoice_equipment_purchase']['l10n_latam_document_number'] = 'FFF-100003'
|
||||
data[f'{cid}_demo_invoice_equipment_purchase']['invoice_line_ids'] = [
|
||||
igv_gyng_tax = self.env['account.tax'].search([('type_tax_use', '=', 'purchase'), ('tax_group_id.name', '=', 'IGV GyNG')], limit=1)
|
||||
move_data[self.company_xmlid('demo_invoice_equipment_purchase')]['partner_id'] = ref('base.res_partner_2').id
|
||||
move_data[self.company_xmlid('demo_invoice_equipment_purchase')]['invoice_date'] = last_month_date
|
||||
move_data[self.company_xmlid('demo_invoice_equipment_purchase')]['l10n_latam_document_number'] = 'FFF-100003'
|
||||
move_data[self.company_xmlid('demo_invoice_equipment_purchase')]['invoice_line_ids'] = [
|
||||
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 500.0, 'quantity': 1, 'tax_ids': [Command.set(igv_gyng_tax.ids)]}),
|
||||
]
|
||||
data[f'{cid}_demo_invoice_6'] = {
|
||||
move_data[self.company_xmlid('demo_invoice_6')] = {
|
||||
'move_type': 'in_invoice',
|
||||
'partner_id': ref('base.res_partner_2').id,
|
||||
'invoice_user_id': ref('base.user_demo').id,
|
||||
|
|
@ -77,7 +75,7 @@ class AccountChartTemplate(models.Model):
|
|||
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 2500.0, 'quantity': 1, 'tax_ids': _get_tax_by_code('1000', 'purchase')}),
|
||||
],
|
||||
}
|
||||
data[f'{cid}_demo_invoice_7'] = {
|
||||
move_data[self.company_xmlid('demo_invoice_7')] = {
|
||||
'move_type': 'in_invoice',
|
||||
'partner_id': ref('base.res_partner_12').id,
|
||||
'invoice_user_id': ref('base.user_demo').id,
|
||||
|
|
@ -89,7 +87,7 @@ class AccountChartTemplate(models.Model):
|
|||
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 25000.0, 'quantity': 3, 'tax_ids': _get_tax_by_code('9995', 'purchase')}),
|
||||
],
|
||||
}
|
||||
data[f'{cid}_demo_invoice_8'] = {
|
||||
move_data[self.company_xmlid('demo_invoice_8')] = {
|
||||
'move_type': 'in_invoice',
|
||||
'partner_id': ref('base.res_partner_12').id,
|
||||
'invoice_user_id': ref('base.user_demo').id,
|
||||
|
|
@ -101,7 +99,7 @@ class AccountChartTemplate(models.Model):
|
|||
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 3, 'quantity': 25000.0, 'tax_ids': _get_tax_by_code('9995', 'purchase')}),
|
||||
],
|
||||
}
|
||||
data[f'{cid}_demo_invoice_9'] = {
|
||||
move_data[self.company_xmlid('demo_invoice_9')] = {
|
||||
'move_type': 'in_invoice',
|
||||
'partner_id': ref('base.res_partner_12').id,
|
||||
'invoice_user_id': ref('base.user_demo').id,
|
||||
|
|
@ -113,7 +111,7 @@ class AccountChartTemplate(models.Model):
|
|||
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 3, 'quantity': 25000.0, 'tax_ids': _get_tax_by_code('9995', 'purchase')}),
|
||||
],
|
||||
}
|
||||
data[f'{cid}_demo_invoice_10'] = {
|
||||
move_data[self.company_xmlid('demo_invoice_10')] = {
|
||||
'move_type': 'out_refund',
|
||||
'partner_id': ref('base.res_partner_12').id,
|
||||
'invoice_user_id': ref('base.user_demo').id,
|
||||
|
|
@ -124,7 +122,7 @@ class AccountChartTemplate(models.Model):
|
|||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 25000.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('9997')}),
|
||||
],
|
||||
}
|
||||
data[f'{cid}_demo_invoice_11'] = {
|
||||
move_data[self.company_xmlid('demo_invoice_11')] = {
|
||||
'move_type': 'in_refund',
|
||||
'partner_id': ref('base.res_partner_12').id,
|
||||
'invoice_user_id': ref('base.user_demo').id,
|
||||
|
|
@ -135,7 +133,7 @@ class AccountChartTemplate(models.Model):
|
|||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 500.0}),
|
||||
],
|
||||
}
|
||||
data[f'{cid}_demo_invoice_12'] = {
|
||||
move_data[self.company_xmlid('demo_invoice_12')] = {
|
||||
'move_type': 'in_invoice',
|
||||
'partner_id': ref('base.res_partner_12').id,
|
||||
'invoice_user_id': ref('base.user_demo').id,
|
||||
|
|
@ -147,4 +145,6 @@ class AccountChartTemplate(models.Model):
|
|||
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 500.0}),
|
||||
],
|
||||
}
|
||||
return model, data
|
||||
move_data[self.company_xmlid('demo_move_auto_reconcile_3')]['l10n_latam_document_number'] = 'FFF-100007'
|
||||
move_data[self.company_xmlid('demo_move_auto_reconcile_4')]['l10n_latam_document_number'] = 'FFF-100008'
|
||||
return move_data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue