You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

831 lines
25 KiB

  1. # Copyright 2017 ACSONE SA/NV
  2. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
  3. from odoo import models, fields, api
  4. DIGITS = (16, 2)
  5. class ReportJournalLedger(models.TransientModel):
  6. _name = 'report_journal_ledger'
  7. _inherit = 'account_financial_report_abstract'
  8. date_from = fields.Date(
  9. required=True
  10. )
  11. date_to = fields.Date(
  12. required=True
  13. )
  14. company_id = fields.Many2one(
  15. comodel_name='res.company',
  16. required=True,
  17. ondelete='cascade'
  18. )
  19. move_target = fields.Selection(
  20. selection='_get_move_targets',
  21. default='all',
  22. required=True,
  23. )
  24. sort_option = fields.Selection(
  25. selection='_get_sort_options',
  26. default='move_name',
  27. required=True,
  28. )
  29. group_option = fields.Selection(
  30. selection='_get_group_options',
  31. default='journal',
  32. required=True,
  33. )
  34. journal_ids = fields.Many2many(
  35. comodel_name='account.journal',
  36. required=True,
  37. )
  38. report_journal_ledger_ids = fields.One2many(
  39. comodel_name='report_journal_ledger_journal',
  40. inverse_name='report_id',
  41. )
  42. report_move_ids = fields.One2many(
  43. comodel_name='report_journal_ledger_move',
  44. inverse_name='report_id',
  45. )
  46. report_move_line_ids = fields.One2many(
  47. comodel_name='report_journal_ledger_move_line',
  48. inverse_name='report_id',
  49. )
  50. report_journal_ledger_tax_line_ids = fields.One2many(
  51. comodel_name='report_journal_ledger_journal_tax_line',
  52. inverse_name='report_id',
  53. )
  54. report_tax_line_ids = fields.One2many(
  55. comodel_name='report_journal_ledger_report_tax_line',
  56. inverse_name='report_id',
  57. )
  58. foreign_currency = fields.Boolean()
  59. with_account_name = fields.Boolean()
  60. @api.model
  61. def _get_move_targets(self):
  62. return self.env['journal.ledger.report.wizard']._get_move_targets()
  63. @api.model
  64. def _get_sort_options(self):
  65. return self.env['journal.ledger.report.wizard']._get_sort_options()
  66. @api.model
  67. def _get_group_options(self):
  68. return self.env['journal.ledger.report.wizard']._get_group_options()
  69. @api.multi
  70. def compute_data_for_report(self):
  71. self.ensure_one()
  72. self._inject_journal_values()
  73. self._inject_move_values()
  74. self._inject_move_line_values()
  75. self._inject_journal_tax_values()
  76. self._update_journal_report_total_values()
  77. if self.group_option == 'none':
  78. self._inject_report_tax_values()
  79. # Refresh cache because all data are computed with SQL requests
  80. self.invalidate_cache()
  81. @api.multi
  82. def _inject_journal_values(self):
  83. self.ensure_one()
  84. sql = """
  85. DELETE
  86. FROM report_journal_ledger_journal
  87. WHERE report_id = %s
  88. """
  89. params = (
  90. self.id,
  91. )
  92. self.env.cr.execute(sql, params)
  93. sql = """
  94. INSERT INTO report_journal_ledger_journal (
  95. create_uid,
  96. create_date,
  97. report_id,
  98. journal_id,
  99. name,
  100. code,
  101. company_id,
  102. currency_id
  103. )
  104. SELECT
  105. %s as create_uid,
  106. NOW() as create_date,
  107. %s as report_id,
  108. aj.id as journal_id,
  109. aj.name as name,
  110. aj.code as code,
  111. aj.company_id as company_id,
  112. COALESCE(aj.currency_id, company.currency_id) as currency_id
  113. FROM
  114. account_journal aj
  115. LEFT JOIN
  116. res_company company on (company.id = aj.company_id)
  117. WHERE
  118. aj.id in %s
  119. AND
  120. aj.company_id = %s
  121. ORDER BY
  122. aj.name
  123. """
  124. params = (
  125. self.env.uid,
  126. self.id,
  127. tuple(self.journal_ids.ids),
  128. self.company_id.id,
  129. )
  130. self.env.cr.execute(sql, params)
  131. @api.multi
  132. def _inject_move_values(self):
  133. self.ensure_one()
  134. sql = """
  135. DELETE
  136. FROM report_journal_ledger_move
  137. WHERE report_id = %s
  138. """
  139. params = (
  140. self.id,
  141. )
  142. self.env.cr.execute(sql, params)
  143. sql = self._get_inject_move_insert()
  144. sql += self._get_inject_move_select()
  145. sql += self._get_inject_move_where_clause()
  146. sql += self._get_inject_move_order_by()
  147. params = self._get_inject_move_params()
  148. self.env.cr.execute(sql, params)
  149. @api.multi
  150. def _get_inject_move_insert(self):
  151. return """
  152. INSERT INTO report_journal_ledger_move (
  153. create_uid,
  154. create_date,
  155. report_id,
  156. report_journal_ledger_id,
  157. move_id,
  158. name,
  159. company_id
  160. )
  161. """
  162. @api.multi
  163. def _get_inject_move_select(self):
  164. return """
  165. SELECT
  166. %s as create_uid,
  167. NOW() as create_date,
  168. rjqj.report_id as report_id,
  169. rjqj.id as report_journal_ledger_id,
  170. am.id as move_id,
  171. am.name as name,
  172. am.company_id as company_id
  173. FROM
  174. account_move am
  175. INNER JOIN
  176. report_journal_ledger_journal rjqj
  177. on (rjqj.journal_id = am.journal_id)
  178. """
  179. @api.multi
  180. def _get_inject_move_where_clause(self):
  181. self.ensure_one()
  182. where_clause = """
  183. WHERE
  184. rjqj.report_id = %s
  185. AND
  186. am.date >= %s
  187. AND
  188. am.date <= %s
  189. """
  190. if self.move_target != 'all':
  191. where_clause += """
  192. AND
  193. am.state = %s
  194. """
  195. return where_clause
  196. @api.multi
  197. def _get_inject_move_order_by(self):
  198. self.ensure_one()
  199. order_by = """
  200. ORDER BY
  201. """
  202. if self.sort_option == 'move_name':
  203. order_by += " am.name"
  204. elif self.sort_option == 'date':
  205. order_by += " am.date, am.name"
  206. return order_by
  207. @api.multi
  208. def _get_inject_move_params(self):
  209. params = [
  210. self.env.uid,
  211. self.id,
  212. self.date_from,
  213. self.date_to
  214. ]
  215. if self.move_target != 'all':
  216. params.append(self.move_target)
  217. return tuple(params)
  218. @api.multi
  219. def _inject_move_line_values(self):
  220. self.ensure_one()
  221. sql = """
  222. DELETE
  223. FROM report_journal_ledger_move_line
  224. WHERE report_id = %s
  225. """
  226. params = (
  227. self.id,
  228. )
  229. self.env.cr.execute(sql, params)
  230. sql = """
  231. INSERT INTO report_journal_ledger_move_line (
  232. create_uid,
  233. create_date,
  234. report_id,
  235. report_journal_ledger_id,
  236. report_move_id,
  237. move_line_id,
  238. account_id,
  239. account,
  240. account_code,
  241. account_type,
  242. partner_id,
  243. partner,
  244. date,
  245. entry,
  246. label,
  247. debit,
  248. credit,
  249. company_currency_id,
  250. amount_currency,
  251. currency_id,
  252. currency_name,
  253. tax_id,
  254. taxes_description,
  255. company_id
  256. )
  257. SELECT
  258. %s as create_uid,
  259. NOW() as create_date,
  260. rjqm.report_id as report_id,
  261. rjqm.report_journal_ledger_id as report_journal_ledger_id,
  262. rjqm.id as report_move_id,
  263. aml.id as move_line_id,
  264. aml.account_id as account_id,
  265. aa.name as account,
  266. aa.code as account_code,
  267. aa.internal_type as account_type,
  268. aml.partner_id as partner_id,
  269. p.name as partner,
  270. aml.date as date,
  271. rjqm.name as entry,
  272. aml.name as label,
  273. aml.debit as debit,
  274. aml.credit as credit,
  275. aml.company_currency_id as currency_id,
  276. aml.amount_currency as amount_currency,
  277. aml.currency_id as currency_id,
  278. currency.name as currency_name,
  279. aml.tax_line_id as tax_id,
  280. CASE
  281. WHEN
  282. aml.tax_line_id is not null
  283. THEN
  284. COALESCE(at.description, at.name)
  285. WHEN
  286. aml.tax_line_id is null
  287. THEN
  288. (SELECT
  289. array_to_string(
  290. array_agg(COALESCE(at.description, at.name)
  291. ), ', ')
  292. FROM
  293. account_move_line_account_tax_rel aml_at_rel
  294. LEFT JOIN
  295. account_tax at on (at.id = aml_at_rel.account_tax_id)
  296. WHERE
  297. aml_at_rel.account_move_line_id = aml.id)
  298. ELSE
  299. ''
  300. END as taxes_description,
  301. aml.company_id as company_id
  302. FROM
  303. account_move_line aml
  304. INNER JOIN
  305. report_journal_ledger_move rjqm
  306. on (rjqm.move_id = aml.move_id)
  307. LEFT JOIN
  308. account_account aa
  309. on (aa.id = aml.account_id)
  310. LEFT JOIN
  311. res_partner p
  312. on (p.id = aml.partner_id)
  313. LEFT JOIN
  314. account_tax at
  315. on (at.id = aml.tax_line_id)
  316. LEFT JOIN
  317. res_currency currency
  318. on (currency.id = aml.currency_id)
  319. WHERE
  320. rjqm.report_id = %s
  321. """
  322. params = (
  323. self.env.uid,
  324. self.id,
  325. )
  326. self.env.cr.execute(sql, params)
  327. @api.multi
  328. def _inject_report_tax_values(self):
  329. self.ensure_one()
  330. sql_distinct_tax_id = """
  331. SELECT
  332. distinct(jrqjtl.tax_id)
  333. FROM
  334. report_journal_ledger_journal_tax_line jrqjtl
  335. WHERE
  336. jrqjtl.report_id = %s
  337. """
  338. self.env.cr.execute(sql_distinct_tax_id, (self.id,))
  339. rows = self.env.cr.fetchall()
  340. tax_ids = set([row[0] for row in rows])
  341. sql = """
  342. INSERT INTO report_journal_ledger_report_tax_line (
  343. create_uid,
  344. create_date,
  345. report_id,
  346. tax_id,
  347. tax_name,
  348. tax_code,
  349. base_debit,
  350. base_credit,
  351. tax_debit,
  352. tax_credit
  353. )
  354. SELECT
  355. %s as create_uid,
  356. NOW() as create_date,
  357. %s as report_id,
  358. %s as tax_id,
  359. at.name as tax_name,
  360. at.description as tax_code,
  361. (
  362. SELECT sum(base_debit)
  363. FROM report_journal_ledger_journal_tax_line jrqjtl2
  364. WHERE jrqjtl2.report_id = %s
  365. AND jrqjtl2.tax_id = %s
  366. ) as base_debit,
  367. (
  368. SELECT sum(base_credit)
  369. FROM report_journal_ledger_journal_tax_line jrqjtl2
  370. WHERE jrqjtl2.report_id = %s
  371. AND jrqjtl2.tax_id = %s
  372. ) as base_credit,
  373. (
  374. SELECT sum(tax_debit)
  375. FROM report_journal_ledger_journal_tax_line jrqjtl2
  376. WHERE jrqjtl2.report_id = %s
  377. AND jrqjtl2.tax_id = %s
  378. ) as tax_debit,
  379. (
  380. SELECT sum(tax_credit)
  381. FROM report_journal_ledger_journal_tax_line jrqjtl2
  382. WHERE jrqjtl2.report_id = %s
  383. AND jrqjtl2.tax_id = %s
  384. ) as tax_credit
  385. FROM
  386. report_journal_ledger_journal_tax_line jrqjtl
  387. LEFT JOIN
  388. account_tax at
  389. on (at.id = jrqjtl.tax_id)
  390. WHERE
  391. jrqjtl.report_id = %s
  392. AND
  393. jrqjtl.tax_id = %s
  394. """
  395. for tax_id in tax_ids:
  396. params = (
  397. self.env.uid,
  398. self.id,
  399. tax_id,
  400. self.id,
  401. tax_id,
  402. self.id,
  403. tax_id,
  404. self.id,
  405. tax_id,
  406. self.id,
  407. tax_id,
  408. self.id,
  409. tax_id,
  410. )
  411. self.env.cr.execute(sql, params)
  412. @api.multi
  413. def _inject_journal_tax_values(self):
  414. self.ensure_one()
  415. sql = """
  416. DELETE
  417. FROM report_journal_ledger_journal_tax_line
  418. WHERE report_id = %s
  419. """
  420. params = (
  421. self.id,
  422. )
  423. self.env.cr.execute(sql, params)
  424. sql_distinct_tax_id = """
  425. SELECT
  426. distinct(jrqml.tax_id)
  427. FROM
  428. report_journal_ledger_move_line jrqml
  429. WHERE
  430. jrqml.report_journal_ledger_id = %s
  431. """
  432. tax_ids_by_journal_id = {}
  433. for report_journal in self.report_journal_ledger_ids:
  434. if report_journal.id not in tax_ids_by_journal_id:
  435. tax_ids_by_journal_id[report_journal.id] = []
  436. self.env.cr.execute(sql_distinct_tax_id, (report_journal.id,))
  437. rows = self.env.cr.fetchall()
  438. tax_ids_by_journal_id[report_journal.id].extend([
  439. row[0] for row in rows if row[0]
  440. ])
  441. sql = """
  442. INSERT INTO report_journal_ledger_journal_tax_line (
  443. create_uid,
  444. create_date,
  445. report_id,
  446. report_journal_ledger_id,
  447. tax_id,
  448. tax_name,
  449. tax_code,
  450. base_debit,
  451. base_credit,
  452. tax_debit,
  453. tax_credit
  454. )
  455. SELECT
  456. %s as create_uid,
  457. NOW() as create_date,
  458. %s as report_id,
  459. %s as report_journal_ledger_id,
  460. %s as tax_id,
  461. at.name as tax_name,
  462. at.description as tax_code,
  463. (
  464. SELECT sum(debit)
  465. FROM report_journal_ledger_move_line jrqml2
  466. WHERE jrqml2.report_journal_ledger_id = %s
  467. AND (
  468. SELECT
  469. count(*)
  470. FROM
  471. account_move_line_account_tax_rel aml_at_rel
  472. WHERE
  473. aml_at_rel.account_move_line_id =
  474. jrqml2.move_line_id
  475. AND
  476. aml_at_rel.account_tax_id = %s
  477. ) > 0
  478. ) as base_debit,
  479. (
  480. SELECT sum(credit)
  481. FROM report_journal_ledger_move_line jrqml2
  482. WHERE jrqml2.report_journal_ledger_id = %s
  483. AND (
  484. SELECT
  485. count(*)
  486. FROM
  487. account_move_line_account_tax_rel aml_at_rel
  488. WHERE
  489. aml_at_rel.account_move_line_id =
  490. jrqml2.move_line_id
  491. AND
  492. aml_at_rel.account_tax_id = %s
  493. ) > 0
  494. ) as base_credit,
  495. (
  496. SELECT sum(debit)
  497. FROM report_journal_ledger_move_line jrqml2
  498. WHERE jrqml2.report_journal_ledger_id = %s
  499. AND jrqml2.tax_id = %s
  500. ) as tax_debit,
  501. (
  502. SELECT sum(credit)
  503. FROM report_journal_ledger_move_line jrqml2
  504. WHERE jrqml2.report_journal_ledger_id = %s
  505. AND jrqml2.tax_id = %s
  506. ) as tax_credit
  507. FROM
  508. report_journal_ledger_journal rjqj
  509. LEFT JOIN
  510. account_tax at
  511. on (at.id = %s)
  512. WHERE
  513. rjqj.id = %s
  514. """
  515. for report_journal_ledger_id in tax_ids_by_journal_id:
  516. tax_ids = tax_ids_by_journal_id[report_journal_ledger_id]
  517. for tax_id in tax_ids:
  518. params = (
  519. self.env.uid,
  520. self.id,
  521. report_journal_ledger_id,
  522. tax_id,
  523. report_journal_ledger_id,
  524. tax_id,
  525. report_journal_ledger_id,
  526. tax_id,
  527. report_journal_ledger_id,
  528. tax_id,
  529. report_journal_ledger_id,
  530. tax_id,
  531. tax_id,
  532. report_journal_ledger_id,
  533. )
  534. self.env.cr.execute(sql, params)
  535. @api.multi
  536. def _update_journal_report_total_values(self):
  537. self.ensure_one()
  538. sql = """
  539. UPDATE
  540. report_journal_ledger_journal rjqj
  541. SET
  542. debit = (
  543. SELECT sum(rjqml.debit)
  544. FROM report_journal_ledger_move_line rjqml
  545. WHERE rjqml.report_journal_ledger_id = rjqj.id
  546. ),
  547. credit = (
  548. SELECT sum(rjqml.credit)
  549. FROM report_journal_ledger_move_line rjqml
  550. WHERE rjqml.report_journal_ledger_id = rjqj.id
  551. )
  552. WHERE
  553. rjqj.report_id = %s
  554. """
  555. self.env.cr.execute(sql, (self.id,))
  556. @api.multi
  557. def print_report(self, report_type):
  558. self.ensure_one()
  559. if report_type == 'xlsx':
  560. report_name = 'a_f_r.report_journal_ledger_xlsx'
  561. else:
  562. report_name = 'account_financial_report.' \
  563. 'report_journal_ledger_qweb'
  564. return self.env['ir.actions.report'].search(
  565. [('report_name', '=', report_name),
  566. ('report_type', '=', report_type)],
  567. limit=1).report_action(self, config=False)
  568. def _get_html(self):
  569. result = {}
  570. rcontext = {}
  571. context = dict(self.env.context)
  572. report = self.browse(context.get('active_id'))
  573. if report:
  574. rcontext['o'] = report
  575. result['html'] = self.env.ref(
  576. 'account_financial_report.report_journal_ledger').render(
  577. rcontext)
  578. return result
  579. @api.model
  580. def get_html(self, given_context=None):
  581. return self._get_html()
  582. @api.model
  583. def _transient_vacuum(self, force=False):
  584. """Remove journal ledger subtables first for avoiding a costly
  585. ondelete operation.
  586. """
  587. # Next 3 lines adapted from super method for mimicking behavior
  588. cls = type(self)
  589. if not force and (cls._transient_check_count < 21):
  590. return True # no vacuum cleaning this time
  591. self.env.cr.execute("DELETE FROM report_journal_ledger_move_line")
  592. self.env.cr.execute("DELETE FROM report_journal_ledger_move")
  593. return super(ReportJournalLedger, self)._transient_vacuum(force=force)
  594. class ReportJournalLedgerJournal(models.TransientModel):
  595. _name = 'report_journal_ledger_journal'
  596. _inherit = 'account_financial_report_abstract'
  597. name = fields.Char(
  598. required=True,
  599. )
  600. code = fields.Char()
  601. report_id = fields.Many2one(
  602. comodel_name='report_journal_ledger',
  603. required=True,
  604. ondelete='cascade'
  605. )
  606. journal_id = fields.Many2one(
  607. comodel_name='account.journal',
  608. required=True,
  609. ondelete='cascade',
  610. )
  611. report_move_ids = fields.One2many(
  612. comodel_name='report_journal_ledger_move',
  613. inverse_name='report_journal_ledger_id',
  614. )
  615. report_tax_line_ids = fields.One2many(
  616. comodel_name='report_journal_ledger_journal_tax_line',
  617. inverse_name='report_journal_ledger_id',
  618. )
  619. debit = fields.Float(
  620. digits=DIGITS,
  621. )
  622. credit = fields.Float(
  623. digits=DIGITS,
  624. )
  625. company_id = fields.Many2one(
  626. comodel_name='res.company',
  627. required=True,
  628. ondelete='cascade'
  629. )
  630. currency_id = fields.Many2one(
  631. comodel_name='res.currency',
  632. )
  633. class ReportJournalLedgerMove(models.TransientModel):
  634. _name = 'report_journal_ledger_move'
  635. _inherit = 'account_financial_report_abstract'
  636. report_id = fields.Many2one(
  637. comodel_name='report_journal_ledger',
  638. required=True,
  639. ondelete='cascade'
  640. )
  641. report_journal_ledger_id = fields.Many2one(
  642. comodel_name='report_journal_ledger_journal',
  643. required=True,
  644. ondelete='cascade',
  645. )
  646. move_id = fields.Many2one(
  647. comodel_name='account.move',
  648. required=True,
  649. ondelete='cascade',
  650. )
  651. report_move_line_ids = fields.One2many(
  652. comodel_name='report_journal_ledger_move_line',
  653. inverse_name='report_move_id',
  654. )
  655. name = fields.Char()
  656. company_id = fields.Many2one(
  657. comodel_name='res.company',
  658. required=True,
  659. ondelete='cascade'
  660. )
  661. class ReportJournalLedgerMoveLine(models.TransientModel):
  662. _name = 'report_journal_ledger_move_line'
  663. _inherit = 'account_financial_report_abstract'
  664. _order = 'partner_id desc, account_id desc'
  665. report_id = fields.Many2one(
  666. comodel_name='report_journal_ledger',
  667. required=True,
  668. ondelete='cascade'
  669. )
  670. report_journal_ledger_id = fields.Many2one(
  671. comodel_name='report_journal_ledger_journal',
  672. required=True,
  673. ondelete='cascade',
  674. )
  675. report_move_id = fields.Many2one(
  676. comodel_name='report_journal_ledger_move',
  677. required=True,
  678. ondelete='cascade',
  679. )
  680. move_line_id = fields.Many2one(
  681. comodel_name='account.move.line',
  682. required=True,
  683. ondelete='cascade',
  684. )
  685. account_id = fields.Many2one(
  686. comodel_name='account.account',
  687. string='Account ID',
  688. )
  689. account = fields.Char()
  690. account_code = fields.Char()
  691. account_type = fields.Char()
  692. partner = fields.Char()
  693. partner_id = fields.Many2one(
  694. comodel_name='res.partner',
  695. string='Partner ID',
  696. )
  697. date = fields.Date()
  698. entry = fields.Char()
  699. label = fields.Char()
  700. debit = fields.Float(
  701. digits=DIGITS,
  702. )
  703. credit = fields.Float(
  704. digits=DIGITS,
  705. )
  706. company_currency_id = fields.Many2one(
  707. comodel_name='res.currency',
  708. )
  709. amount_currency = fields.Monetary(
  710. currency_field='currency_id',
  711. )
  712. currency_id = fields.Many2one(
  713. comodel_name='res.currency',
  714. )
  715. currency_name = fields.Char()
  716. taxes_description = fields.Char()
  717. tax_id = fields.Many2one(
  718. comodel_name='account.tax'
  719. )
  720. company_id = fields.Many2one(
  721. comodel_name='res.company',
  722. required=True,
  723. ondelete='cascade'
  724. )
  725. class ReportJournalLedgerReportTaxLine(models.TransientModel):
  726. _name = 'report_journal_ledger_report_tax_line'
  727. _inherit = 'account_financial_report_abstract'
  728. _order = 'tax_code'
  729. report_id = fields.Many2one(
  730. comodel_name='report_journal_ledger',
  731. required=True,
  732. ondelete='cascade'
  733. )
  734. tax_id = fields.Many2one(
  735. comodel_name='account.tax'
  736. )
  737. tax_name = fields.Char()
  738. tax_code = fields.Char()
  739. base_debit = fields.Float(
  740. digits=DIGITS,
  741. )
  742. base_credit = fields.Float(
  743. digits=DIGITS,
  744. )
  745. base_balance = fields.Float(
  746. digits=DIGITS,
  747. compute='_compute_base_balance',
  748. )
  749. tax_debit = fields.Float(
  750. digits=DIGITS,
  751. )
  752. tax_credit = fields.Float(
  753. digits=DIGITS,
  754. )
  755. tax_balance = fields.Float(
  756. digits=DIGITS,
  757. compute='_compute_tax_balance'
  758. )
  759. @api.multi
  760. def _compute_base_balance(self):
  761. for rec in self:
  762. rec.base_balance = rec.base_debit - rec.base_credit
  763. @api.multi
  764. def _compute_tax_balance(self):
  765. for rec in self:
  766. rec.tax_balance = rec.tax_debit - rec.tax_credit
  767. class ReportJournalLedgerJournalTaxLine(models.TransientModel):
  768. _name = 'report_journal_ledger_journal_tax_line'
  769. _inherit = 'report_journal_ledger_report_tax_line'
  770. _order = 'tax_code'
  771. report_journal_ledger_id = fields.Many2one(
  772. comodel_name='report_journal_ledger_journal',
  773. required=True,
  774. ondelete='cascade',
  775. )