Debian Codegraph @

addons/l10n_bg_ledger/models/account_move.py

raw symbols SCIP
1 from odoo import api, fields, models
2
3
4 class AccountMove(models.Model):
5 _inherit = "account.move"
6
7 l10n_bg_document_type = fields.Selection(
8 string="Document Type (BG)",
9 selection='_l10n_bg_document_type_selection_values',
10 compute='_compute_l10n_bg_document_type',
11 readonly=False,
12 store=True,
13 copy=False,
14 )
15 l10n_bg_document_number = fields.Char(string="Document Number (BG)", compute='_compute_l10n_bg_document_number')
16 l10n_bg_exemption_reason = fields.Selection(string="Exemption reason (BG)", selection=[
17 ('01', '01 - A delivery under Part 1 of Appendix 2 of LVAT'),
18 ('02', '02 - A delivery under Part 2 of Appendix 2 of LVAT'),
19 ('03', '03 - Import under Appendix 3 of VAT act'),
20 ])
21
22 def _l10n_bg_document_type_selection_values(self):
23 return [
24 ('01', '01 - Invoice'),
25 ('02', '02 - Debit notice'),
26 ('03', '03 - Credit notice'),
27 ('07', '07 - Customs declaration'),
28 ('09', '09 - Protocol or another document'),
29 ('11', '11 - Invoice - cash account'),
30 ('12', '12 - Debit notification - cash account'),
31 ('13', '13 - Credit notification - cash account'),
32 ('81', '81 - Report for the sales carried out'),
33 ('82', '82 - Report for the sales carried out by a special levying procedure'),
34 ('91', '91 - Protocol of due tax under Art. 151c, Para 3 of the Act'),
35 ('93', '93 - Protocol of due tax under Art. 151c, Para 7 of the Act with a recipient being a person not applying the special regime'),
36 ('94', '94 - Protocol of due tax under Art. 151c, Para 7 of the Act with a recipient being a person applying the special regime'),
37 ]
38
39 @api.depends('journal_id', 'move_type')
40 def _compute_l10n_bg_document_type(self):
41 for move in self:
42 if move.journal_id:
43 if 'debit_origin_id' in self._fields and move.debit_origin_id:
44 move.l10n_bg_document_type = move.journal_id.l10n_bg_debit_notes
45 elif move.move_type in ('out_invoice', 'in_invoice'):
46 move.l10n_bg_document_type = move.journal_id.l10n_bg_customer_invoice
47 elif move.move_type in ('in_refund', 'out_refund'):
48 move.l10n_bg_document_type = move.journal_id.l10n_bg_credit_notes
49
50 @api.depends('l10n_bg_document_type', 'move_type', 'state', 'ref', 'name')
51 def _compute_l10n_bg_document_number(self):
52 for move in self:
53 if move.state == 'draft':
54 move.l10n_bg_document_number = ""
55 elif move.is_sale_document(include_receipts=True):
56 move.l10n_bg_document_number = move.name
57 else:
58 move.l10n_bg_document_number = move.ref