Alexis de Lattre
7 years ago
22 changed files with 524 additions and 1 deletions
-
74agreement_account/README.rst
-
3agreement_account/__init__.py
-
22agreement_account/__manifest__.py
-
35agreement_account/demo/demo.xml
-
4agreement_account/models/__init__.py
-
15agreement_account/models/account_invoice.py
-
42agreement_account/models/sale_agreement.py
-
3agreement_account/security/ir.model.access.csv
-
17agreement_account/security/sale_agreement_security.xml
-
37agreement_account/views/account_invoice.xml
-
77agreement_account/views/sale_agreement.xml
-
49agreement_sale/README.rst
-
4agreement_sale/__init__.py
-
23agreement_sale/__manifest__.py
-
4agreement_sale/models/__init__.py
-
14agreement_sale/models/sale_agreement.py
-
20agreement_sale/models/sale_order.py
-
24agreement_sale/views/sale_agreement.xml
-
35agreement_sale/views/sale_order.xml
-
3agreement_sale/wizard/__init__.py
-
17agreement_sale/wizard/sale_make_invoice_advance.py
-
3oca_dependencies.txt
@ -0,0 +1,74 @@ |
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
|||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
=================== |
|||
Agreement (Account) |
|||
=================== |
|||
|
|||
This module adds a *Sale Agreement* object with the following properties: |
|||
|
|||
* link to a customer, |
|||
* name, |
|||
* code, |
|||
* signature date. |
|||
|
|||
You can link a customer invoice to a sale agreement. |
|||
|
|||
If you also install the module *agreement_sale*, you will be able to link a quotation/sale order to an agreement, and this information will be copied to the invoice. |
|||
|
|||
A *Sale Agreement* can be used for: |
|||
|
|||
* Private business contracts |
|||
* Public markets |
|||
|
|||
It will allow you to group all the orders and invoices related to the same agreement and display the references of this agreement on the documents where you have to display it. For example, the *code* property of the sale agreement is used in the module *account_invoice_factur-x* (from the `edi <https://github.com/OCA/edi>`_ project) in the XML tag */CrossIndustryInvoice/SupplyChainTradeTransaction/ApplicableHeaderTradeAgreement/ContractReferencedDocument/IssuerAssignedID*. |
|||
|
|||
The main differences with the *Contract* object of Odoo: |
|||
|
|||
* a contract is an analytic account; a sale agreement is not related to analytic accounting. |
|||
* on the invoice, the contract/analytic account is per-line; a sale agreement is attached to the invoice (not to the lines). |
|||
* a sale agreement is a very simple object with just a few basic fields; a contract has a lot of properties and a lot of related features. |
|||
|
|||
Configuration |
|||
============= |
|||
|
|||
Go to the menu *Accounting > Configuration > Management > Sale Agreements* to create new agreements. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
|||
:alt: Try me on Runbot |
|||
:target: https://runbot.odoo-community.org/runbot/110/10.0 |
|||
|
|||
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. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Alexis de Lattre <alexis.delattre@akretion.com> |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: https://odoo-community.org/logo.png |
|||
:alt: Odoo Community Association |
|||
:target: https://odoo-community.org |
|||
|
|||
This module is maintained by the OCA. |
|||
|
|||
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. |
|||
|
|||
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import models |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
{ |
|||
'name': u'Agreement (Account)', |
|||
'summary': "Adds a sale agreement object linked to a customer invoice", |
|||
'version': '10.0.1.0.0', |
|||
'category': 'Contract', |
|||
'author': "Akretion,Odoo Community Association (OCA)", |
|||
'website': 'http://www.akretion.com', |
|||
'license': 'AGPL-3', |
|||
'depends': ['account'], |
|||
'data': [ |
|||
'security/ir.model.access.csv', |
|||
'security/sale_agreement_security.xml', |
|||
'views/sale_agreement.xml', |
|||
'views/account_invoice.xml', |
|||
], |
|||
'demo': ['demo/demo.xml'], |
|||
'installable': True, |
|||
} |
@ -0,0 +1,35 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
© 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
--> |
|||
|
|||
<odoo noupdate="1"> |
|||
|
|||
|
|||
<record id="market1" model="sale.agreement"> |
|||
<field name="code">C2C-IT0042</field> |
|||
<field name="name">Hardware IT</field> |
|||
<field name="partner_id" ref="base.res_partner_12"/> |
|||
</record> |
|||
|
|||
<record id="market2" model="sale.agreement"> |
|||
<field name="code">C2C-IT0043</field> |
|||
<field name="name">Fiber access office Lausanne</field> |
|||
<field name="partner_id" ref="base.res_partner_12"/> |
|||
</record> |
|||
|
|||
<record id="market3" model="sale.agreement"> |
|||
<field name="code">AGR-VETO001</field> |
|||
<field name="name">Vétérinaire</field> |
|||
<field name="partner_id" ref="base.res_partner_2"/> |
|||
</record> |
|||
|
|||
<record id="market4" model="sale.agreement"> |
|||
<field name="code">AGR-TEL001</field> |
|||
<field name="name">Wazo IPBX deployment and maintenance</field> |
|||
<field name="partner_id" ref="base.res_partner_2"/> |
|||
</record> |
|||
|
|||
|
|||
</odoo> |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import sale_agreement |
|||
from . import account_invoice |
@ -0,0 +1,15 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2017 Akretion (http://www.akretion.com) |
|||
# @author: Alexis de Lattre <alexis.delattre@akretion.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import models, fields |
|||
|
|||
|
|||
class AccountInvoice(models.Model): |
|||
_inherit = 'account.invoice' |
|||
|
|||
sale_agreement_id = fields.Many2one( |
|||
'sale.agreement', string='Sale Agreement', ondelete='restrict', |
|||
readonly=True, states={'draft': [('readonly', False)]}, |
|||
track_visibility='onchange') |
@ -0,0 +1,42 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
|
|||
from odoo import models, fields |
|||
|
|||
|
|||
class SaleAgreement(models.Model): |
|||
_name = 'sale.agreement' |
|||
_description = 'Sale Agreement' |
|||
|
|||
code = fields.Char( |
|||
string='Code', required=True, copy=False) |
|||
name = fields.Char(string='Name', required=True) |
|||
partner_id = fields.Many2one( |
|||
'res.partner', string='Customer', ondelete='restrict', required=True, |
|||
domain=[('customer', '=', True), ('parent_id', '=', False)]) |
|||
company_id = fields.Many2one( |
|||
'res.company', string='Company', |
|||
default=lambda self: self.env['res.company']._company_default_get( |
|||
'sale.agreement')) |
|||
active = fields.Boolean(string='Active', default=True) |
|||
signature_date = fields.Date(string='Signature Date') |
|||
invoice_ids = fields.One2many( |
|||
'account.invoice', 'sale_agreement_id', string='Invoices', |
|||
readonly=True) |
|||
|
|||
def name_get(self): |
|||
res = [] |
|||
for agr in self: |
|||
name = agr.name |
|||
if agr.code: |
|||
name = u'[%s] %s' % (agr.code, agr.name) |
|||
res.append((agr.id, name)) |
|||
return res |
|||
|
|||
_sql_constraints = [( |
|||
'code_partner_company_unique', |
|||
'unique(code, partner_id, company_id)', |
|||
'This sale agreement code already exists for this customer!' |
|||
)] |
@ -0,0 +1,3 @@ |
|||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink |
|||
access_sale_agreement_read,Read access on sale.agreement to Employees,model_sale_agreement,base.group_user,1,0,0,0 |
|||
access_sale_agreement_full,Full access on sale.agreement to Invoicing and Payment grp,model_sale_agreement,account.group_account_invoice,1,1,1,1 |
@ -0,0 +1,17 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- |
|||
© 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
--> |
|||
|
|||
<odoo noupdate="1"> |
|||
|
|||
|
|||
<record id="sale_agreement_rule" model="ir.rule"> |
|||
<field name="name">Sale Agreement multi-company</field> |
|||
<field name="model_id" ref="model_sale_agreement"/> |
|||
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'child_of', [user.company_id.id])]</field> |
|||
</record> |
|||
|
|||
|
|||
</odoo> |
@ -0,0 +1,37 @@ |
|||
<?xml version="1.0"?> |
|||
<!-- |
|||
© 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
--> |
|||
|
|||
<odoo> |
|||
|
|||
|
|||
<record id="invoice_form" model="ir.ui.view"> |
|||
<field name="name">sale.agreement.account.invoice.form</field> |
|||
<field name="model">account.invoice</field> |
|||
<field name="inherit_id" ref="account.invoice_form"/> |
|||
<field name="arch" type="xml"> |
|||
<xpath expr="//page/group/group/field[@name='name']" position="after"> |
|||
<field name="sale_agreement_id" |
|||
domain="[('partner_id', 'child_of', commercial_partner_id)]" |
|||
context="{'default_partner_id': commercial_partner_id}"/> |
|||
<field name="commercial_partner_id" invisible="1"/> |
|||
</xpath> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="view_account_invoice_filter" model="ir.ui.view"> |
|||
<field name="name">sale.agreement.account.invoice.search</field> |
|||
<field name="model">account.invoice</field> |
|||
<field name="inherit_id" ref="account.view_account_invoice_filter"/> |
|||
<field name="arch" type="xml"> |
|||
<group expand="0" position="inside"> |
|||
<filter string="Sale Agreements" name="sale_agreement_groupby" |
|||
context="{'group_by': 'sale_agreement_id'}"/> |
|||
</group> |
|||
</field> |
|||
</record> |
|||
|
|||
|
|||
</odoo> |
@ -0,0 +1,77 @@ |
|||
<?xml version="1.0"?> |
|||
<!-- |
|||
© 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
--> |
|||
|
|||
<odoo> |
|||
|
|||
|
|||
<record id="sale_agreement_form" model="ir.ui.view"> |
|||
<field name="name">sale.agreement.form</field> |
|||
<field name="model">sale.agreement</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="Sale Agreement"> |
|||
<div class="oe_button_box" name="button_box"> |
|||
<button name="toggle_active" type="object" |
|||
class="oe_stat_button" icon="fa-archive"> |
|||
<field name="active" widget="boolean_button" |
|||
options='{"terminology": "archive"}'/> |
|||
</button> |
|||
</div> |
|||
<group name="main"> |
|||
<field name="partner_id"/> |
|||
<field name="name"/> |
|||
<field name="code"/> |
|||
<field name="signature_date"/> |
|||
<field name="company_id" groups="base.group_multi_company"/> |
|||
</group> |
|||
<group string="Invoices" name="invoices"> |
|||
<field name="invoice_ids" nolabel="1"/> |
|||
</group> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="sale_agreement_tree" model="ir.ui.view"> |
|||
<field name="name">sale.agreement.tree</field> |
|||
<field name="model">sale.agreement</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="Sale Agreements"> |
|||
<field name="partner_id"/> |
|||
<field name="code"/> |
|||
<field name="name"/> |
|||
<field name="signature_date"/> |
|||
<field name="company_id" groups="base.group_multi_company"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="sale_agreement_search" model="ir.ui.view"> |
|||
<field name="name">sale.agreement.search</field> |
|||
<field name="model">sale.agreement</field> |
|||
<field name="arch" type="xml"> |
|||
<search string="Search Sale Agreements"> |
|||
<field name="name" filter_domain="['|', ('name', 'ilike', self), ('code', 'ilike', self)]" string="Name or Number"/> |
|||
<field name="partner_id"/> |
|||
<filter name="inactive" string="Archived" domain="[('active', '=', False)]"/> |
|||
<group name="groupby"> |
|||
<filter name="partner_groupby" string="Customer" |
|||
context="{'group_by': 'partner_id'}"/> |
|||
<filter name="signature_date_groupby" string="Signature Date" |
|||
context="{'group_by': 'signature_date'}"/> |
|||
</group> |
|||
</search> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="sale_agreement_action" model="ir.actions.act_window"> |
|||
<field name="name">Sale Agreements</field> |
|||
<field name="res_model">sale.agreement</field> |
|||
<field name="view_mode">tree,form</field> |
|||
</record> |
|||
|
|||
<menuitem id="sale_agreement_menu" action="sale_agreement_action" |
|||
parent="account.account_management_menu" sequence="100"/> |
|||
|
|||
</odoo> |
@ -0,0 +1,49 @@ |
|||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg |
|||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
================ |
|||
Agreement (Sale) |
|||
================ |
|||
|
|||
This module is an extension of the module *agreement_account* for sale orders. |
|||
|
|||
With this module, you will be able to link a quotation/sale order to a sale agreement. Upon invoice creation, this information will be copied to the customer invoice. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
|||
:alt: Try me on Runbot |
|||
:target: https://runbot.odoo-community.org/runbot/110/10.0 |
|||
|
|||
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. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Alexis de Lattre <alexis.delattre@akretion.com> |
|||
|
|||
Maintainer |
|||
---------- |
|||
|
|||
.. image:: https://odoo-community.org/logo.png |
|||
:alt: Odoo Community Association |
|||
:target: https://odoo-community.org |
|||
|
|||
This module is maintained by the OCA. |
|||
|
|||
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. |
|||
|
|||
To contribute to this module, please visit https://odoo-community.org. |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import models |
|||
from . import wizard |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
{ |
|||
'name': u'Agreement (Sale)', |
|||
'summary': "Link a sale agreement to a sale order and copy to invoice", |
|||
'version': '10.0.1.0.0', |
|||
'category': 'Contract', |
|||
'author': "Akretion,Odoo Community Association (OCA)", |
|||
'website': 'http://www.akretion.com', |
|||
'license': 'AGPL-3', |
|||
'depends': [ |
|||
'agreement_account', |
|||
'sale_commercial_partner', |
|||
], |
|||
'data': [ |
|||
'views/sale_order.xml', |
|||
'views/sale_agreement.xml', |
|||
], |
|||
'installable': True, |
|||
'auto_install': True, |
|||
} |
@ -0,0 +1,4 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import sale_order |
|||
from . import sale_agreement |
@ -0,0 +1,14 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
|
|||
from odoo import models, fields |
|||
|
|||
|
|||
class SaleAgreement(models.Model): |
|||
_inherit = 'sale.agreement' |
|||
|
|||
sale_ids = fields.One2many( |
|||
'sale.order', 'sale_agreement_id', string='Sale Orders', readonly=True, |
|||
domain=[('state', 'not in', ('draft', 'sent', 'cancel'))]) |
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2017 Akretion (http://www.akretion.com) |
|||
# @author: Alexis de Lattre <alexis.delattre@akretion.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import models, fields |
|||
|
|||
|
|||
class SaleOrder(models.Model): |
|||
_inherit = 'sale.order' |
|||
|
|||
sale_agreement_id = fields.Many2one( |
|||
'sale.agreement', string='Sale Agreement', ondelete='restrict', |
|||
track_visibility='onchange', readonly=True, |
|||
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}) |
|||
|
|||
def _prepare_invoice(self): |
|||
vals = super(SaleOrder, self)._prepare_invoice() |
|||
vals['sale_agreement_id'] = self.sale_agreement_id.id or False |
|||
return vals |
@ -0,0 +1,24 @@ |
|||
<?xml version="1.0"?> |
|||
<!-- |
|||
© 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
--> |
|||
|
|||
<odoo> |
|||
|
|||
|
|||
<record id="sale_agreement_form" model="ir.ui.view"> |
|||
<field name="name">sale.agreement.form</field> |
|||
<field name="model">sale.agreement</field> |
|||
<field name="inherit_id" ref="agreement_account.sale_agreement_form"/> |
|||
<field name="arch" type="xml"> |
|||
<group name="invoices" position="after"> |
|||
<group name="sale_orders" string="Sales Orders"> |
|||
<field name="sale_ids" nolabel="1"/> |
|||
</group> |
|||
</group> |
|||
</field> |
|||
</record> |
|||
|
|||
|
|||
</odoo> |
@ -0,0 +1,35 @@ |
|||
<?xml version="1.0"?> |
|||
<!-- |
|||
© 2017 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>) |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
--> |
|||
|
|||
<odoo> |
|||
|
|||
|
|||
<record id="view_order_form" model="ir.ui.view"> |
|||
<field name="name">sale.agreement.sale.order.form</field> |
|||
<field name="model">sale.order</field> |
|||
<field name="inherit_id" ref="sale_commercial_partner.view_order_form"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="client_order_ref" position="after"> |
|||
<field name="sale_agreement_id" |
|||
domain="[('partner_id', 'child_of', commercial_partner_id)]" |
|||
context="{'default_partner_id': commercial_partner_id}"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="view_sales_order_filter" model="ir.ui.view"> |
|||
<field name="name">sale.agreement.sale.order.search</field> |
|||
<field name="model">sale.order</field> |
|||
<field name="inherit_id" ref="sale.view_sales_order_filter"/> |
|||
<field name="arch" type="xml"> |
|||
<group expand="0" position="inside"> |
|||
<filter string="Sale Agreement" name="sale_agreement_groupby" context="{'group_by': 'sale_agreement_id'}"/> |
|||
</group> |
|||
</field> |
|||
</record> |
|||
|
|||
|
|||
</odoo> |
@ -0,0 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from . import sale_make_invoice_advance |
@ -0,0 +1,17 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2017 Akretion (http://www.akretion.com) |
|||
# @author: Alexis de Lattre <alexis.delattre@akretion.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import models |
|||
|
|||
|
|||
class SaleAdvancePaymentInv(models.TransientModel): |
|||
_inherit = 'sale.advance.payment.inv' |
|||
|
|||
def _create_invoice(self, order, so_line, amount): |
|||
inv = super(SaleAdvancePaymentInv, self)._create_invoice( |
|||
order, so_line, amount) |
|||
if order.sale_agreement_id: |
|||
inv.sale_agreement_id = order.sale_agreement_id.id |
|||
return inv |
@ -1 +1,2 @@ |
|||
bank-payment |
|||
bank-payment |
|||
sale-workflow |
Write
Preview
Loading…
Cancel
Save
Reference in new issue