| 1 |
|
| 2 |
|
| 3 |
from datetime import datetime, timedelta |
| 4 |
from odoo import api, Command, models |
| 5 |
|
| 6 |
|
| 7 |
class AccountChartTemplate(models.AbstractModel): |
| 8 |
_inherit = "account.chart.template" |
| 9 |
|
| 10 |
@api.model |
| 11 |
def _get_demo_data_move(self, company=False): |
| 12 |
def _get_tax_by_code(code, type_tax='sale'): |
| 13 |
taxes = self.env['account.tax'].search([ |
| 14 |
('type_tax_use', '=', type_tax), ('l10n_pe_edi_tax_code', '=', code)], limit=1) |
| 15 |
return [Command.set(taxes.ids)] |
| 16 |
|
| 17 |
move_data = super()._get_demo_data_move(company) |
| 18 |
ref = self.env.ref |
| 19 |
last_month_date = datetime.strptime(move_data[self.company_xmlid('demo_invoice_1')]['invoice_date'], '%Y-%m-%d') - timedelta(days=1) |
| 20 |
if company.account_fiscal_country_id.code == "PE": |
| 21 |
move_data[self.company_xmlid('demo_invoice_1')]['invoice_date'] = last_month_date |
| 22 |
move_data[self.company_xmlid('demo_invoice_1')]['l10n_latam_document_number'] = 'FFF-0000001' |
| 23 |
move_data[self.company_xmlid('demo_invoice_1')]['invoice_line_ids'] = [ |
| 24 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 25000.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('9997')}), |
| 25 |
] |
| 26 |
move_data[self.company_xmlid('demo_invoice_2')]['invoice_date'] = last_month_date |
| 27 |
move_data[self.company_xmlid('demo_invoice_2')]['l10n_latam_document_number'] = 'FFF-0000002' |
| 28 |
move_data[self.company_xmlid('demo_invoice_2')]['invoice_line_ids'] = [ |
| 29 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 12500.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('1000')}), |
| 30 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 1000.0, 'tax_ids': _get_tax_by_code('9997')}), |
| 31 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 1500.0, 'tax_ids': _get_tax_by_code('9998')}), |
| 32 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 12500.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('1000')}), |
| 33 |
] |
| 34 |
move_data[self.company_xmlid('demo_invoice_3')]['invoice_date'] = last_month_date |
| 35 |
move_data[self.company_xmlid('demo_invoice_3')]['l10n_latam_document_type_id'] = ref('l10n_pe.document_type08').id |
| 36 |
move_data[self.company_xmlid('demo_invoice_3')]['l10n_latam_document_number'] = 'NDI-0000001' |
| 37 |
move_data[self.company_xmlid('demo_invoice_3')]['invoice_line_ids'] = [ |
| 38 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 12500.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('1000')}), |
| 39 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 1000.0, 'tax_ids': _get_tax_by_code('9997')}), |
| 40 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 1500.0, 'tax_ids': _get_tax_by_code('9998')}), |
| 41 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 12500.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('1000')}), |
| 42 |
] |
| 43 |
move_data[self.company_xmlid('demo_invoice_followup')]['move_type'] = 'in_invoice' |
| 44 |
move_data[self.company_xmlid('demo_invoice_followup')]['partner_id'] = ref('base.res_partner_2').id |
| 45 |
move_data[self.company_xmlid('demo_invoice_followup')]['invoice_date'] = last_month_date |
| 46 |
move_data[self.company_xmlid('demo_invoice_followup')]['l10n_latam_document_number'] = 'FFF-100001' |
| 47 |
move_data[self.company_xmlid('demo_invoice_followup')]['invoice_line_ids'] = [ |
| 48 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 500.0}), |
| 49 |
] |
| 50 |
move_data[self.company_xmlid('demo_invoice_5')]['partner_id'] = ref('base.res_partner_2').id |
| 51 |
move_data[self.company_xmlid('demo_invoice_5')]['invoice_date'] = last_month_date |
| 52 |
move_data[self.company_xmlid('demo_invoice_5')]['l10n_latam_document_number'] = 'FFF-100002' |
| 53 |
move_data[self.company_xmlid('demo_invoice_5')]['invoice_line_ids'] = [ |
| 54 |
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')}), |
| 55 |
] |
| 56 |
igv_gyng_tax = self.env['account.tax'].search([('type_tax_use', '=', 'purchase'), ('tax_group_id.name', '=', 'IGV GyNG')], limit=1) |
| 57 |
move_data[self.company_xmlid('demo_invoice_equipment_purchase')]['partner_id'] = ref('base.res_partner_2').id |
| 58 |
move_data[self.company_xmlid('demo_invoice_equipment_purchase')]['invoice_date'] = last_month_date |
| 59 |
move_data[self.company_xmlid('demo_invoice_equipment_purchase')]['l10n_latam_document_number'] = 'FFF-100003' |
| 60 |
move_data[self.company_xmlid('demo_invoice_equipment_purchase')]['invoice_line_ids'] = [ |
| 61 |
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 500.0, 'quantity': 1, 'tax_ids': [Command.set(igv_gyng_tax.ids)]}), |
| 62 |
] |
| 63 |
move_data[self.company_xmlid('demo_invoice_6')] = { |
| 64 |
'move_type': 'in_invoice', |
| 65 |
'partner_id': ref('base.res_partner_2').id, |
| 66 |
'invoice_user_id': ref('base.user_demo').id, |
| 67 |
'invoice_payment_term_id': ref('account.account_payment_term_end_following_month').id, |
| 68 |
'invoice_date': last_month_date, |
| 69 |
'l10n_latam_document_number': 'FFF-100004', |
| 70 |
'invoice_line_ids': [ |
| 71 |
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 500.0, 'quantity': 1, 'tax_ids': _get_tax_by_code('9997', 'purchase')}), |
| 72 |
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 1000.0, 'quantity': 1, 'tax_ids': _get_tax_by_code('1000', 'purchase')}), |
| 73 |
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 1500.0, 'quantity': 2, 'tax_ids': _get_tax_by_code('9996', 'purchase')}), |
| 74 |
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 2000.0, 'quantity': 1, 'tax_ids': _get_tax_by_code('9998', 'purchase')}), |
| 75 |
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 2500.0, 'quantity': 1, 'tax_ids': _get_tax_by_code('1000', 'purchase')}), |
| 76 |
], |
| 77 |
} |
| 78 |
move_data[self.company_xmlid('demo_invoice_7')] = { |
| 79 |
'move_type': 'in_invoice', |
| 80 |
'partner_id': ref('base.res_partner_12').id, |
| 81 |
'invoice_user_id': ref('base.user_demo').id, |
| 82 |
'invoice_payment_term_id': ref('account.account_payment_term_end_following_month').id, |
| 83 |
'invoice_date': last_month_date, |
| 84 |
'l10n_latam_document_number': 'FFF-000005', |
| 85 |
'l10n_latam_document_type_id': ref('l10n_pe.document_type91').id, |
| 86 |
'invoice_line_ids': [ |
| 87 |
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 25000.0, 'quantity': 3, 'tax_ids': _get_tax_by_code('9995', 'purchase')}), |
| 88 |
], |
| 89 |
} |
| 90 |
move_data[self.company_xmlid('demo_invoice_8')] = { |
| 91 |
'move_type': 'in_invoice', |
| 92 |
'partner_id': ref('base.res_partner_12').id, |
| 93 |
'invoice_user_id': ref('base.user_demo').id, |
| 94 |
'invoice_payment_term_id': ref('account.account_payment_term_end_following_month').id, |
| 95 |
'invoice_date': last_month_date, |
| 96 |
'l10n_latam_document_number': '118-145266', |
| 97 |
'l10n_latam_document_type_id': ref('l10n_pe.document_type50').id, |
| 98 |
'invoice_line_ids': [ |
| 99 |
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 3, 'quantity': 25000.0, 'tax_ids': _get_tax_by_code('9995', 'purchase')}), |
| 100 |
], |
| 101 |
} |
| 102 |
move_data[self.company_xmlid('demo_invoice_9')] = { |
| 103 |
'move_type': 'in_invoice', |
| 104 |
'partner_id': ref('base.res_partner_12').id, |
| 105 |
'invoice_user_id': ref('base.user_demo').id, |
| 106 |
'invoice_payment_term_id': ref('account.account_payment_term_end_following_month').id, |
| 107 |
'invoice_date': last_month_date, |
| 108 |
'l10n_latam_document_number': 'FFF-100009', |
| 109 |
'l10n_latam_document_type_id': ref('l10n_pe.document_type91').id, |
| 110 |
'invoice_line_ids': [ |
| 111 |
Command.create({'product_id': ref('product.product_delivery_01').id, 'price_unit': 3, 'quantity': 25000.0, 'tax_ids': _get_tax_by_code('9995', 'purchase')}), |
| 112 |
], |
| 113 |
} |
| 114 |
move_data[self.company_xmlid('demo_invoice_10')] = { |
| 115 |
'move_type': 'out_refund', |
| 116 |
'partner_id': ref('base.res_partner_12').id, |
| 117 |
'invoice_user_id': ref('base.user_demo').id, |
| 118 |
'invoice_payment_term_id': ref('account.account_payment_term_end_following_month').id, |
| 119 |
'invoice_date': last_month_date, |
| 120 |
'l10n_latam_document_number': 'CNE-0000001', |
| 121 |
'invoice_line_ids': [ |
| 122 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 25000.0, 'price_unit': 3.0, 'tax_ids': _get_tax_by_code('9997')}), |
| 123 |
], |
| 124 |
} |
| 125 |
move_data[self.company_xmlid('demo_invoice_11')] = { |
| 126 |
'move_type': 'in_refund', |
| 127 |
'partner_id': ref('base.res_partner_12').id, |
| 128 |
'invoice_user_id': ref('base.user_demo').id, |
| 129 |
'invoice_payment_term_id': ref('account.account_payment_term_end_following_month').id, |
| 130 |
'invoice_date': last_month_date, |
| 131 |
'l10n_latam_document_number': 'FFF-100005', |
| 132 |
'invoice_line_ids': [ |
| 133 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 500.0}), |
| 134 |
], |
| 135 |
} |
| 136 |
move_data[self.company_xmlid('demo_invoice_12')] = { |
| 137 |
'move_type': 'in_invoice', |
| 138 |
'partner_id': ref('base.res_partner_12').id, |
| 139 |
'invoice_user_id': ref('base.user_demo').id, |
| 140 |
'l10n_latam_document_type_id': ref('l10n_pe.document_type08').id, |
| 141 |
'invoice_payment_term_id': ref('account.account_payment_term_end_following_month').id, |
| 142 |
'invoice_date': last_month_date, |
| 143 |
'l10n_latam_document_number': 'FFF-100006', |
| 144 |
'invoice_line_ids': [ |
| 145 |
Command.create({'product_id': ref('product.consu_delivery_03').id, 'quantity': 1.0, 'price_unit': 500.0}), |
| 146 |
], |
| 147 |
} |
| 148 |
move_data[self.company_xmlid('demo_move_auto_reconcile_3')]['l10n_latam_document_number'] = 'FFF-100007' |
| 149 |
move_data[self.company_xmlid('demo_move_auto_reconcile_4')]['l10n_latam_document_number'] = 'FFF-100008' |
| 150 |
return move_data |