[ADD] sale_contract_asset: link module between account_asset and sale_contract
Allows you to set deferred revenue categories on your contracts and contract templates; contracts will set their revenue category on the lines of their invoices
This commit is contained in:
@@ -0,0 +1 @@
|
||||
import models
|
||||
@@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
{
|
||||
'name': 'Deferred revenue management for contracts',
|
||||
'version': '1.0',
|
||||
'category': 'Sales Management',
|
||||
'description': """
|
||||
This module allows you to set a deferred revenue on your subscription contracts.
|
||||
""",
|
||||
'author': 'Odoo S.A.',
|
||||
'website': 'https://www.odoo.com/',
|
||||
'depends': ['sale_contract', 'account_asset'],
|
||||
'data': [
|
||||
'views/account_analytic_account_views.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
import account_analytic_account
|
||||
@@ -0,0 +1,29 @@
|
||||
from openerp import models, fields, api
|
||||
|
||||
|
||||
class account_analytic_account(models.Model):
|
||||
_name = "account.analytic.account"
|
||||
_inherit = "account.analytic.account"
|
||||
|
||||
asset_category_id = fields.Many2one('account.asset.category', 'Deferred Revenue Category',
|
||||
help="This asset category will be applied to the lines of the contract's invoices.",
|
||||
domain="[('type','=','sale')]")
|
||||
|
||||
@api.multi
|
||||
def on_change_template(self, template_id, date_start=False):
|
||||
res = super(account_analytic_account, self).on_change_template(template_id, date_start)
|
||||
|
||||
template = self.browse(template_id)
|
||||
if template.asset_category_id:
|
||||
res['value']['asset_category_id'] = template.asset_category_id.id
|
||||
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def _prepare_invoice_lines(self, contract, fiscal_position_id):
|
||||
inv_lines = super(account_analytic_account, self)._prepare_invoice_lines(contract, fiscal_position_id)
|
||||
|
||||
for line in inv_lines:
|
||||
line[2]['asset_category_id'] = contract.asset_category_id and contract.asset_category_id.id
|
||||
|
||||
return inv_lines
|
||||
@@ -0,0 +1,14 @@
|
||||
<odoo>
|
||||
<!-- Inherited Analytic Account form for contracts -->
|
||||
<record id="account_analytic_account_form_form" model="ir.ui.view">
|
||||
<field name="name">account.analytic.account.invoice.form.inherit</field>
|
||||
<field name="model">account.analytic.account</field>
|
||||
<field name="inherit_id" ref="sale_contract.account_analytic_account_form_form"/>
|
||||
<field eval="40" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr='//field[@name="pricelist_id"]' position='after'>
|
||||
<field name="asset_category_id" attrs="{'invisible': [('contract_type','!=','subscription')]}" context="{'default_type':'sale'}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user