Debian Codegraph @

addons/l10n_pk/demo/account_demo.py

raw symbols SCIP
1 # Part of Odoo. See LICENSE file for full copyright and licensing details.
2
3 from datetime import datetime
4 from dateutil.relativedelta import relativedelta
5
6 from odoo import api, fields, models, Command
7
8
9 class AccountChartTemplate(models.AbstractModel):
10 _inherit = "account.chart.template"
11
12 @api.model
13 def _get_demo_data_move(self, company=False):
14 moves = super()._get_demo_data_move(company)
15 if company.account_fiscal_country_id.code == "PK":
16 sale_journal = self.env['account.journal'].search(
17 domain=[
18 *self.env['account.journal']._check_company_domain((company or self.env.company).id),
19 ('type', '=', 'sale'),
20 ], limit=1)
21 moves.update({
22 self.company_xmlid('l10n_pk_demo_invoice_1'): {
23 'move_type': 'out_invoice',
24 'partner_id': 'l10n_pk.res_partner_punjab',
25 'invoice_user_id': 'base.user_demo',
26 'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
27 'invoice_date': fields.Datetime.today() - relativedelta(days=1),
28 'journal_id': sale_journal.id,
29 'invoice_line_ids': [
30 Command.create({
31 'product_id': 'product.product_product_8',
32 'quantity': 2,
33 'price_unit': 40000.0,
34 'tax_ids': [Command.set([
35 'pk_sales_tax_services_10'
36 ])],
37 }),
38 Command.create({
39 'product_id': 'product.product_product_9',
40 'quantity': 3,
41 'price_unit': 400.0,
42 'tax_ids': [Command.set([
43 'pk_sales_tax_services_17',
44 'pk_tax_wh_S_1'
45 ])],
46 }),
47 Command.create({
48 'product_id': 'product.product_product_10',
49 'quantity': 4,
50 'price_unit': 300.0,
51 'tax_ids': [Command.set([
52 'pk_sales_tax_services_5'
53 ])],
54 }),
55 ],
56 },
57 self.company_xmlid('l10n_pk_demo_invoice_2'): {
58 'move_type': 'out_invoice',
59 'partner_id': 'l10n_pk.res_partner_punjab',
60 'invoice_user_id': 'base.user_demo',
61 'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
62 'invoice_date': fields.Datetime.today() - relativedelta(days=2),
63 'journal_id': sale_journal.id,
64 'invoice_line_ids': [
65 Command.create({
66 'product_id': 'product.product_product_9',
67 'quantity': 2,
68 'price_unit': 4000.0,
69 'tax_ids': [Command.set([
70 'pk_sales_tax_services_10'
71 ])],
72 }),
73 Command.create({
74 'product_id': 'product.product_product_10',
75 'quantity': 3,
76 'price_unit': 300.0,
77 'tax_ids': [Command.set([
78 'pk_sales_tax_services_5'
79 ])],
80 }),
81 ],
82 },
83 self.company_xmlid('l10n_pk_demo_invoice_3'): {
84 'move_type': 'out_invoice',
85 'partner_id': 'base.res_partner_3',
86 'invoice_user_id': 'base.user_demo',
87 'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
88 'invoice_date': fields.Datetime.today() - relativedelta(days=3),
89 'journal_id': sale_journal.id,
90 'invoice_line_ids': [
91 Command.create({
92 'product_id': 'product.product_product_4',
93 'quantity': 10,
94 'price_unit': 800.0,
95 'tax_ids': False,
96 }),
97 ]
98 },
99 self.company_xmlid('l10n_pk_demo_reconcile_1'): {
100 'move_type': 'out_refund',
101 'partner_id': 'l10n_pk.res_partner_punjab',
102 'invoice_date': fields.Datetime.today() - relativedelta(days=1),
103 'delivery_date': fields.Datetime.today() - relativedelta(days=1),
104 'invoice_line_ids': [
105 Command.create({
106 'product_id': 'product.product_product_8',
107 'quantity': 2,
108 'price_unit': 40000.0,
109 'tax_ids': [Command.set([
110 'pk_sales_tax_services_10'
111 ])],
112 }),
113 Command.create({
114 'product_id': 'product.product_product_9',
115 'quantity': 3,
116 'price_unit': 400.0,
117 'tax_ids': [Command.set([
118 'pk_sales_tax_services_10',
119 'pk_tax_wh_S_5'
120 ])],
121 }),
122 Command.create({
123 'product_id': 'product.product_product_10',
124 'quantity': 4,
125 'price_unit': 300.0,
126 'tax_ids': [Command.set([
127 'pk_sales_tax_services_5'
128 ])],
129 }),
130 ],
131 },
132 self.company_xmlid('l10n_pk_demo_reconcile_2'): {
133 'move_type': 'out_refund',
134 'partner_id': 'base.res_partner_3',
135 'invoice_date': fields.Datetime.today() - relativedelta(days=2),
136 'delivery_date': fields.Datetime.today() - relativedelta(days=2),
137 'invoice_line_ids': [
138 Command.create({
139 'product_id': 'product.product_product_4',
140 'quantity': 10,
141 'price_unit': 800.0,
142 'tax_ids': False,
143 }),
144 ]
145 },
146 self.company_xmlid('l10n_pk_demo_vendor_bill_1'): {
147 'ref': 'INV/001',
148 'move_type': 'in_invoice',
149 'partner_id': 'l10n_pk.res_partner_islamabad',
150 'invoice_user_id': 'base.user_demo',
151 'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
152 'invoice_date': fields.Datetime.today() - relativedelta(days=1),
153 'invoice_line_ids': [
154 Command.create({
155 'product_id': 'product.consu_delivery_01',
156 'quantity': 1,
157 'price_unit': 1000.0,
158 'tax_ids': [Command.set([
159 'pk_sales_tax_services_15'
160 ])],
161 }),
162 Command.create({
163 'product_id': 'product.consu_delivery_03',
164 'quantity': 1,
165 'price_unit': 2000.0,
166 'tax_ids': [Command.set([
167 'pk_sales_tax_services_10',
168 'pk_tax_wh_S_1'
169 ])],
170 }),
171 ]
172 },
173 self.company_xmlid('l10n_pk_demo_vendor_bill_2'): {
174 'ref': 'INV/002',
175 'move_type': 'in_invoice',
176 'partner_id': 'l10n_pk.res_partner_islamabad',
177 'invoice_user_id': 'base.user_demo',
178 'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
179 'invoice_date': fields.Datetime.today() - relativedelta(days=2),
180 'invoice_line_ids': [
181 Command.create({
182 'product_id': 'product.product_product_8',
183 'quantity': 4,
184 'price_unit': 1000.0,
185 'tax_ids': [Command.set([
186 'pk_sales_tax_17'
187 ])],
188 }),
189 Command.create({
190 'product_id': 'product.product_product_7',
191 'quantity': 3,
192 'price_unit': 2000.0,
193 'tax_ids': [Command.set([
194 'pk_sales_tax_services_10'
195 ])],
196 }),
197 ]
198 },
199 self.company_xmlid('l10n_pk_demo_vendor_bill_3'): {
200 'ref': 'INV/003',
201 'move_type': 'in_invoice',
202 'partner_id': 'l10n_pk.res_partner_islamabad',
203 'invoice_user_id': 'base.user_demo',
204 'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
205 'invoice_date': fields.Datetime.today() - relativedelta(days=3),
206 'invoice_line_ids': [
207 Command.create({
208 'product_id': 'product.product_product_9',
209 'quantity': 1,
210 'price_unit': 1000.0,
211 'tax_ids': [Command.set([
212 'pk_sales_tax_services_17'
213 ])],
214 }),
215 Command.create({
216 'product_id': 'product.product_product_10',
217 'quantity': 1,
218 'price_unit': 2000.0,
219 'tax_ids': [Command.set([
220 'pk_sales_tax_services_10',
221 'pk_tax_wh_S_5'
222 ])],
223 }),
224 ]
225 },
226 })
227 return moves
228
229 def _post_load_demo_data(self, company=False):
230 company = company or self.env.company
231 if company.account_fiscal_country_id.code == "PK":
232 invoices = (
233 self.ref('l10n_pk_demo_invoice_1')
234 + self.ref('l10n_pk_demo_invoice_2')
235 + self.ref('l10n_pk_demo_invoice_3')
236 + self.ref('l10n_pk_demo_reconcile_1')
237 + self.ref('l10n_pk_demo_reconcile_2')
238 + self.ref('l10n_pk_demo_vendor_bill_1')
239 + self.ref('l10n_pk_demo_vendor_bill_2')
240 + self.ref('l10n_pk_demo_vendor_bill_3')
241 )
242 for move in invoices:
243 move.action_post()
244 return super()._post_load_demo_data(company)