mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[IMP][10.0] contract: Add templating (#42)
Add template functionality for contracts
This commit is contained in:
committed by
Pedro M. Baeza
parent
c5d3267ee7
commit
3e876611f5
71
contract/models/account_analytic_contract.py
Normal file
71
contract/models/account_analytic_contract.py
Normal file
@@ -0,0 +1,71 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2004-2010 OpenERP SA
|
||||
# © 2014 Angel Moya <angel.moya@domatix.com>
|
||||
# © 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||
# Copyright 2016-2017 LasLabs Inc.
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class AccountAnalyticContract(models.Model):
|
||||
_name = 'account.analytic.contract'
|
||||
|
||||
# These fields will not be synced to the contract
|
||||
NO_SYNC = [
|
||||
'name',
|
||||
]
|
||||
|
||||
name = fields.Char(
|
||||
required=True,
|
||||
)
|
||||
pricelist_id = fields.Many2one(
|
||||
comodel_name='product.pricelist',
|
||||
string='Pricelist',
|
||||
)
|
||||
recurring_invoice_line_ids = fields.One2many(
|
||||
comodel_name='account.analytic.invoice.line',
|
||||
inverse_name='analytic_account_id',
|
||||
copy=True,
|
||||
string='Invoice Lines',
|
||||
)
|
||||
recurring_rule_type = fields.Selection(
|
||||
[('daily', 'Day(s)'),
|
||||
('weekly', 'Week(s)'),
|
||||
('monthly', 'Month(s)'),
|
||||
('monthlylastday', 'Month(s) last day'),
|
||||
('yearly', 'Year(s)'),
|
||||
],
|
||||
default='monthly',
|
||||
string='Recurrence',
|
||||
help="Specify Interval for automatic invoice generation.",
|
||||
)
|
||||
recurring_invoicing_type = fields.Selection(
|
||||
[('pre-paid', 'Pre-paid'),
|
||||
('post-paid', 'Post-paid'),
|
||||
],
|
||||
default='pre-paid',
|
||||
string='Invoicing type',
|
||||
help="Specify if process date is 'from' or 'to' invoicing date",
|
||||
)
|
||||
recurring_interval = fields.Integer(
|
||||
default=1,
|
||||
string='Repeat Every',
|
||||
help="Repeat every (Days/Week/Month/Year)",
|
||||
)
|
||||
journal_id = fields.Many2one(
|
||||
'account.journal',
|
||||
string='Journal',
|
||||
default=lambda s: s._default_journal(),
|
||||
domain="[('type', '=', 'sale'),('company_id', '=', company_id)]",
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _default_journal(self):
|
||||
company_id = self.env.context.get(
|
||||
'company_id', self.env.user.company_id.id)
|
||||
domain = [
|
||||
('type', '=', 'sale'),
|
||||
('company_id', '=', company_id)]
|
||||
return self.env['account.journal'].search(domain, limit=1)
|
||||
Reference in New Issue
Block a user