diff options
Diffstat (limited to 'addons/account/models/chart_template.py')
| -rw-r--r-- | addons/account/models/chart_template.py | 106 |
1 files changed, 48 insertions, 58 deletions
diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 6a5220f50ed..6dd67e8fce5 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -698,44 +698,42 @@ class AccountChartTemplate(models.Model): """ This method generates a dictionary of all the values for the account.reconcile.model that will be created. """ self.ensure_one() + account_reconcile_model_lines = self.env['account.reconcile.model.line.template'].search([ + ('model_id', '=', account_reconcile_model.id) + ]) return { - 'name': account_reconcile_model.name, - 'sequence': account_reconcile_model.sequence, - 'has_second_line': account_reconcile_model.has_second_line, - 'company_id': company.id, - 'account_id': acc_template_ref[account_reconcile_model.account_id.id], - 'label': account_reconcile_model.label, - 'to_check': account_reconcile_model.to_check, - 'amount_type': account_reconcile_model.amount_type, - 'force_tax_included': account_reconcile_model.force_tax_included, - 'amount': account_reconcile_model.amount, - 'tax_ids': [[4, tax_template_ref[tax.id], 0] for tax in account_reconcile_model.tax_ids], - 'second_account_id': account_reconcile_model.second_account_id and acc_template_ref[account_reconcile_model.second_account_id.id] or False, - 'second_label': account_reconcile_model.second_label, - 'second_amount_type': account_reconcile_model.second_amount_type, - 'force_second_tax_included': account_reconcile_model.force_second_tax_included, - 'second_amount': account_reconcile_model.second_amount, - 'rule_type': account_reconcile_model.rule_type, - 'auto_reconcile': account_reconcile_model.auto_reconcile, - 'match_journal_ids': [(6, None, account_reconcile_model.match_journal_ids.ids)], - 'match_nature': account_reconcile_model.match_nature, - 'match_amount': account_reconcile_model.match_amount, - 'match_amount_min': account_reconcile_model.match_amount_min, - 'match_amount_max': account_reconcile_model.match_amount_max, - 'match_label': account_reconcile_model.match_label, - 'match_label_param': account_reconcile_model.match_label_param, - 'match_note': account_reconcile_model.match_note, - 'match_note_param': account_reconcile_model.match_note_param, - 'match_transaction_type': account_reconcile_model.match_transaction_type, - 'match_transaction_type_param': account_reconcile_model.match_transaction_type_param, - 'match_same_currency': account_reconcile_model.match_same_currency, - 'match_total_amount': account_reconcile_model.match_total_amount, - 'match_total_amount_param': account_reconcile_model.match_total_amount_param, - 'match_partner': account_reconcile_model.match_partner, - 'match_partner_ids': [(6, None, account_reconcile_model.match_partner_ids.ids)], - 'match_partner_category_ids': [(6, None, account_reconcile_model.match_partner_category_ids.ids)], - 'second_tax_ids': [[4, tax_template_ref[tax.id], 0] for tax in account_reconcile_model.second_tax_ids], - } + 'name': account_reconcile_model.name, + 'sequence': account_reconcile_model.sequence, + 'company_id': company.id, + 'rule_type': account_reconcile_model.rule_type, + 'auto_reconcile': account_reconcile_model.auto_reconcile, + 'to_check': account_reconcile_model.to_check, + 'match_journal_ids': [(6, None, account_reconcile_model.match_journal_ids.ids)], + 'match_nature': account_reconcile_model.match_nature, + 'match_amount': account_reconcile_model.match_amount, + 'match_amount_min': account_reconcile_model.match_amount_min, + 'match_amount_max': account_reconcile_model.match_amount_max, + 'match_label': account_reconcile_model.match_label, + 'match_label_param': account_reconcile_model.match_label_param, + 'match_note': account_reconcile_model.match_note, + 'match_note_param': account_reconcile_model.match_note_param, + 'match_transaction_type': account_reconcile_model.match_transaction_type, + 'match_transaction_type_param': account_reconcile_model.match_transaction_type_param, + 'match_same_currency': account_reconcile_model.match_same_currency, + 'match_total_amount': account_reconcile_model.match_total_amount, + 'match_total_amount_param': account_reconcile_model.match_total_amount_param, + 'match_partner': account_reconcile_model.match_partner, + 'match_partner_ids': [(6, None, account_reconcile_model.match_partner_ids.ids)], + 'match_partner_category_ids': [(6, None, account_reconcile_model.match_partner_category_ids.ids)], + 'line_ids': [(0, 0, { + 'account_id': acc_template_ref[line.account_id.id], + 'label': line.label, + 'amount_type': line.amount_type, + 'force_tax_included': line.force_tax_included, + 'amount_string': line.amount_string, + 'tax_ids': [[4, tax_template_ref[tax.id], 0] for tax in line.tax_ids], + }) for line in account_reconcile_model_lines], + } def generate_account_reconcile_model(self, tax_template_ref, acc_template_ref, company): """ This method creates account reconcile models @@ -1175,31 +1173,23 @@ class AccountReconcileModelTemplate(models.Model): match_partner_category_ids = fields.Many2many('res.partner.category', string='Restrict Partner Categories to', help='The reconciliation model will only be applied to the selected customer/vendor categories.') - # First part fields. + line_ids = fields.One2many('account.reconcile.model.line.template', 'model_id') + decimal_separator = fields.Char(help="Every character that is nor a digit nor this separator will be removed from the matching string") + + +class AccountReconcileModelLineTemplate(models.Model): + _name = "account.reconcile.model.line.template" + _description = 'Reconcile Model Line Template' + + model_id = fields.Many2one('account.reconcile.model.template') + sequence = fields.Integer(required=True, default=10) account_id = fields.Many2one('account.account.template', string='Account', ondelete='cascade', domain=[('deprecated', '=', False)]) label = fields.Char(string='Journal Item Label') amount_type = fields.Selection([ ('fixed', 'Fixed'), ('percentage', 'Percentage of balance'), ('regex', 'From label'), - ], required=True, default='percentage') - amount = fields.Float(string='Write-off Amount', digits=0, required=True, default=100.0, help="Fixed amount will count as a debit if it is negative, as a credit if it is positive.") - amount_from_label_regex = fields.Char(string="Amount from Label (regex)", default=r"([\d\.,]+)") - decimal_separator = fields.Char(help="Every character that is nor a digit nor this separator will be removed from the matching string") - force_tax_included = fields.Boolean(string='Tax Included in Price', - help='Force the tax to be managed as a price included tax.') - # Second part fields. - has_second_line = fields.Boolean(string='Add a second line', default=False) + ], required=True, default='percentage') + amount_string = fields.Char(string="Amount") + force_tax_included = fields.Boolean(string='Tax Included in Price', help='Force the tax to be managed as a price included tax.') tax_ids = fields.Many2many('account.tax.template', string='Taxes', ondelete='restrict') - second_account_id = fields.Many2one('account.account.template', string='Second Account', ondelete='cascade', domain=[('deprecated', '=', False)]) - second_label = fields.Char(string='Second Journal Item Label') - second_amount_type = fields.Selection([ - ('fixed', 'Fixed'), - ('percentage', 'Percentage of amount'), - ('regex', 'From label'), - ], string="Second Amount type",required=True, default='percentage') - second_amount = fields.Float(string='Second Write-off Amount', digits=0, required=True, default=100.0, help="Fixed amount will count as a debit if it is negative, as a credit if it is positive.") - second_amount_from_label_regex = fields.Char(string="Second Amount from Label (regex)", default=r"([\d\.,]+)") - force_second_tax_included = fields.Boolean(string='Second Tax Included in Price', - help='Force the second tax to be managed as a price included tax.') - second_tax_ids = fields.Many2many('account.tax.template', relation='account_reconcile_model_tmpl_account_tax_bis_rel', string='Second Taxes', ondelete='restrict') |
