mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[ADD] Contract section module (#177)
This commit is contained in:
committed by
Pedro M. Baeza
parent
19d6a841b1
commit
d1eb4bc29f
76
contract_section/README.rst
Normal file
76
contract_section/README.rst
Normal file
@@ -0,0 +1,76 @@
|
||||
===================================================
|
||||
Contracts Management - Add section to invoice lines
|
||||
===================================================
|
||||
|
||||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge2| image:: https://img.shields.io/badge/github-OCA%2Fcontract-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/contract/tree/11.0/contract_section
|
||||
:alt: OCA/contract
|
||||
.. |badge3| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/contract-11-0/contract-11-0-contract_section
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/110/11.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4|
|
||||
|
||||
Enable the use of sections on the contract.
|
||||
|
||||
**Table of contents**
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
Create a contract with sections. When the invoice is created, the sections are
|
||||
transfered to the invoice.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/contract/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/contract/issues/new?body=module:%20contract_section%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Authors
|
||||
~~~~~~~
|
||||
|
||||
* Road-Support
|
||||
|
||||
Contributors
|
||||
~~~~~~~~~~~~
|
||||
|
||||
* Roel Adriaans <roel@road-support.nl>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
||||
This module is maintained by the OCA.
|
||||
|
||||
.. image:: https://odoo-community.org/logo.png
|
||||
:alt: Odoo Community Association
|
||||
:target: https://odoo-community.org
|
||||
|
||||
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
This module is part of the `OCA/contract <https://github.com/OCA/contract/tree/11.0/contract_section>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
1
contract_section/__init__.py
Normal file
1
contract_section/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import models
|
||||
22
contract_section/__manifest__.py
Normal file
22
contract_section/__manifest__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Copyright 2018 Road-Support - Roel Adriaans
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Contracts Management - Add section to invoice lines',
|
||||
'version': '11.0.1.0.0',
|
||||
'category': 'Contract Management',
|
||||
'license': 'AGPL-3',
|
||||
'author': "Road-Support, "
|
||||
"Odoo Community Association (OCA)",
|
||||
'website': 'https://github.com/oca/contract',
|
||||
'depends': [
|
||||
'contract',
|
||||
'sale'
|
||||
],
|
||||
'data': [
|
||||
'views/account_analytic_account.xml',
|
||||
'views/account_analytic_contract.xml',
|
||||
],
|
||||
'development_status': 'alpha',
|
||||
'installable': True,
|
||||
}
|
||||
4
contract_section/models/__init__.py
Normal file
4
contract_section/models/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import account_analytic_account
|
||||
from . import account_analytic_contract_line
|
||||
17
contract_section/models/account_analytic_account.py
Normal file
17
contract_section/models/account_analytic_account.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Copyright 2018 Road-Support - Roel Adriaans
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class AccountAnalyticAccount(models.Model):
|
||||
_inherit = 'account.analytic.account'
|
||||
|
||||
@api.model
|
||||
def _prepare_invoice_line(self, line, invoice_id):
|
||||
invoice_line_vals = super(AccountAnalyticAccount, self). \
|
||||
_prepare_invoice_line(line, invoice_id)
|
||||
invoice_line_vals.update({
|
||||
'layout_category_id': line.layout_category_id.id,
|
||||
})
|
||||
return invoice_line_vals
|
||||
11
contract_section/models/account_analytic_contract_line.py
Normal file
11
contract_section/models/account_analytic_contract_line.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# Copyright 2018 Road-Support - Roel Adriaans
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class AccountAnalyticContractLine(models.Model):
|
||||
_inherit = 'account.analytic.contract.line'
|
||||
|
||||
layout_category_id = fields.Many2one('sale.layout_category',
|
||||
string='Section')
|
||||
1
contract_section/readme/CONTRIBUTORS.rst
Normal file
1
contract_section/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1 @@
|
||||
* Roel Adriaans <roel@road-support.nl>
|
||||
1
contract_section/readme/DESCRIPTION.rst
Normal file
1
contract_section/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1 @@
|
||||
Enable the use of sections on the contract and the contract template.
|
||||
2
contract_section/readme/USAGE.rst
Normal file
2
contract_section/readme/USAGE.rst
Normal file
@@ -0,0 +1,2 @@
|
||||
Create a contract with sections. When the invoice is created, the sections are
|
||||
transferred to the invoice.
|
||||
4
contract_section/tests/__init__.py
Normal file
4
contract_section/tests/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import test_contract
|
||||
31
contract_section/tests/test_contract.py
Normal file
31
contract_section/tests/test_contract.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# Copyright 2016 Tecnativa - Carlos Dauden
|
||||
# Copyright 2017 Tecnativa - Pedro M. Baeza
|
||||
# Copyright 2018 Roel Adriaans - roel@road-support.nl
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo.addons.contract.tests.test_contract import TestContractBase
|
||||
|
||||
|
||||
class TestContract(TestContractBase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# Reuse the tests from the contract module, but replace the
|
||||
# contract line
|
||||
super(TestContract, cls).setUpClass()
|
||||
cls.acct_line.unlink()
|
||||
cls.section = cls.env.ref('sale.sale_layout_cat_2')
|
||||
cls.line_vals.update({
|
||||
'layout_category_id': cls.section.id,
|
||||
})
|
||||
cls.acct_line = cls.env['account.analytic.invoice.line'].create(
|
||||
cls.line_vals,
|
||||
)
|
||||
|
||||
def test_create_invoice(self):
|
||||
""" Create contract with section"""
|
||||
self.assertTrue(self.acct_line.layout_category_id)
|
||||
self.contract.recurring_create_invoice()
|
||||
invoice_id = self.env['account.invoice'].search(
|
||||
[('contract_id', '=', self.contract.id)])
|
||||
self.assertEqual(invoice_id.invoice_line_ids.layout_category_id.id,
|
||||
self.line_vals['layout_category_id'])
|
||||
14
contract_section/views/account_analytic_account.xml
Normal file
14
contract_section/views/account_analytic_account.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="account_analytic_account_recurring_section_form" model="ir.ui.view">
|
||||
<field name="name">Account Analytic account Form View</field>
|
||||
<field name="model">account.analytic.account</field>
|
||||
<field name="inherit_id" ref="contract.account_analytic_account_recurring_form_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr='//field[@name="recurring_invoice_line_ids"]/tree//field[@name="name"]'
|
||||
position="after">
|
||||
<field name="layout_category_id" groups="sale.group_sale_layout"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
14
contract_section/views/account_analytic_contract.xml
Normal file
14
contract_section/views/account_analytic_contract.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="account_analytic_contract_recurring_section_form" model="ir.ui.view">
|
||||
<field name="name">Account Analytic contract Form View</field>
|
||||
<field name="model">account.analytic.contract</field>
|
||||
<field name="inherit_id" ref="contract.account_analytic_contract_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr='//field[@name="recurring_invoice_line_ids"]/tree//field[@name="name"]'
|
||||
position="after">
|
||||
<field name="layout_category_id" groups="sale.group_sale_layout"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user