19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:31:16 +01:00
parent 89c6e82fe7
commit 1b82c20a58
572 changed files with 43570 additions and 53303 deletions

View file

@ -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

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="partner_demo_company_pe" model="res.partner">
<record id="base.partner_demo_company_pe" model="res.partner" forcecreate="1">
<field name="name">PE Company</field>
<field name="vat">10071037199</field>
<field name="street">Calle Las Tortugas</field>
@ -12,24 +12,27 @@
<field name="email">info@company.peexample.com</field>
<field name="website">www.peexample.com</field>
<field name="l10n_latam_identification_type_id" ref="it_RUC"/>
<field name="is_company" eval="True"/>
</record>
<record id="demo_company_pe" model="res.company">
<record id="base.demo_company_pe" model="res.company" forcecreate="1">
<field name="name">PE Company</field>
<field name="partner_id" ref="partner_demo_company_pe"/>
<field name="partner_id" ref="base.partner_demo_company_pe"/>
</record>
<function model="res.company" name="_onchange_country_id">
<value eval="[ref('demo_company_pe')]"/>
<value eval="[ref('base.demo_company_pe')]"/>
</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('l10n_pe.demo_company_pe'))]}"/>
<value eval="{'company_ids': [(4, ref('base.demo_company_pe'))]}"/>
</function>
<function model="account.chart.template" name="try_loading">
<value eval="[ref('l10n_pe.pe_chart_template')]"/>
<value model="res.company" eval="obj().env.ref('l10n_pe.demo_company_pe')"/>
<value eval="[]"/>
<value>pe</value>
<value model="res.company" eval="obj().env.ref('base.demo_company_pe')"/>
<value name="install_demo" eval="True"/>
</function>
</odoo>