Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions website_portal_contract/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

=======================
Website Portal Contract
=======================

Extension of contract and website_portal that allows contracts to
be shown in website portal. Each contract now has a website template tied to it.

Usage
=====

`Usage Video <https://youtu.be/PSulRVdh4C4>`_

To edit the website template, go to:

* `Invoicing` in the top navigation.
* `Contracts` => `Website Templates`.
* When viewing a template in form view, click `View Template`.
This will direct you to an edit page of the template in website if
your user has edit permissions.

To view the live template in `My Account` in website, assign the template
to a contract and go to:

* `Website`
* Click on your username then select `My Account` in the dropdown.
* Click `Your Contracts`, then the relevant contract. Your template will show under
the `Contract` section header, which is also shown in the edit template view for reference.

.. 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

Known Issues / Roadmap
======================

* Add token access to controller
* Add functionality to print contracts in website portal

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 smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Brett Wood <bwood@laslabs.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.
6 changes: 6 additions & 0 deletions website_portal_contract/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
from . import controllers
34 changes: 34 additions & 0 deletions website_portal_contract/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright 2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Website Portal Contract",
"summary": "Extends website portal with contracts.",
"version": "10.0.1.0.0",
"category": "Contract Management",
"website": "https://laslabs.com",
"author": "LasLabs, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"contract",
"contract_show_invoice",
"website_quote",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious - why are we dependent on website_quote?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since both modules have the exact same general xml structure, some of the javascript functionality that already exists in website_quote can be re-used in this module.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Score!

],
"data": [
"security/ir.model.access.csv",
"data/website_contract_template_data.xml",
"views/account_analytic_account_view.xml",
"views/account_analytic_contract_template_view.xml",
"views/account_analytic_contract_view.xml",
"views/website_portal_contract_templates.xml",
],
"demo": [
"demo/account_analytic_invoice_line_demo.xml",
"demo/account_analytic_contract_demo.xml",
"demo/account_analytic_account_demo.xml",
"demo/assets_demo.xml",
],
}
5 changes: 5 additions & 0 deletions website_portal_contract/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import main
74 changes: 74 additions & 0 deletions website_portal_contract/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
# Copyright 2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import http
from odoo.http import request

from odoo.addons.website_portal_sale.controllers.main import website_account


class WebsiteAccount(website_account):

@http.route()
def account(self, **kw):
response = super(WebsiteAccount, self).account(**kw)
contracts = request.env['account.analytic.account']._search_contracts()
response.qcontext.update({
'contract_count': len(contracts),
})
return response


class WebsiteContract(http.Controller):

@http.route(
['/my/contracts'],
type='http',
auth='user',
website=True,
)
def portal_my_contracts(self):
account_mod = request.env['account.analytic.account']
values = {
'user': request.env.user,
'contracts': account_mod._search_contracts(),
}
return request.render(
'website_portal_contract.portal_my_contracts',
values,
)

@http.route(
['/contract/<model("account.analytic.account"):contract>'],
type='http',
auth='user',
website=True
)
def portal_contract(self, contract):
action = request.env.ref(
'contract.action_account_analytic_overdue_all'
)
values = {
'user': request.env.user,
'contract': contract,
'action': action.id,
}
return request.render(
'website_portal_contract.website_contract',
values,
)

@http.route(
["/contract/template/"
"<model('account.analytic.contract.template'):contract>"],
type='http',
auth='user',
website=True,
)
def template_view(self, contract, **kwargs):
values = {'template': contract}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested

return request.render(
'website_portal_contract.website_contract_template',
values,
)
115 changes: 115 additions & 0 deletions website_portal_contract/data/website_contract_template_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 LasLabs Inc.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo noupdate="1">

<record id="website_contract_template_default" model="account.analytic.contract.template">
<field name="name">Default Template</field>
<field name="website_description" type="xml">
<section data-snippet-id="text-block">
<section>
<h1 class="page-header">Contract</h1>
<p class="bg-danger">Disclaimer: This demo contract is not to be used for real business purposes.</p>
<p>
This Agreement is made to the start date of Date, between Client, having its principal place of Client Address
and Company, having its principal place of Company Address.
In consideration of Client retaining Company to perform support services for Client, it is agreed as follows:
</p>
</section>
<section>
<h3>Compensation and Term</h3>
<p>
Client hereby retains Company and Company hereby agrees to perform the following services: Consulting services of Company
as required by Client,through December 31, 20--. Company will at various times perform services at Client's headquarters,
at other Client facilities, or at Company facilities, as directed by Client. Company will perform the services at various
times and for various durations as directed by Client.
</p>
<h4>The following fees shall apply:</h4>
<p>
<strong>..........$X per hour for services.</strong>
</p>
<p>
Reasonable and necessary business and travel expenses actually incurred by Company shall be reimbursed by Client upon submission
of expense reports with back-up documentation. All such expenses and all travel plans must be approved in advance by Client.
Company shall provide detailed invoices and shall maintain, and provide, upon request, backup documentation for a period of
one year from the date of the respective invoices. Client shall make full payment for services within thirty days of invoice.
If Company brings a legal action to collect any sums due under this Agreement, it shall be entitled to collect, in addition
to all damages, its costs of collection, including reasonable attorney's fees. This Agreement shall commence on the date stated
above, and shall remain in effect until all obligations under this Agreement have been properly completed. Either party to this
Agreement may terminate this Agreement with or without cause by providing at least 21 days written notice to the other party.
</p>
</section>
<section>
<h5>Warranties by Company</h5>
<p>
Company represents and warrants to Client that it has the experience and ability to perform the services required by this
Agreement; that it will perform said services in a professional, competent and timely manner; that it has the power to enter into
and perform this Agreement; and that its performance of this Agreement shall not infringe upon or violate the rights of any third
party or violate any federal, provincial and municipal laws. Client shall provide requisite training for additional products or services
required by this Agreement which are not within Company's area of expertise.
</p>
</section>
<section>
<h3>Independent Contractor</h3>
<p>
Company acknowledges that the services rendered under this Agreement shall be solely as an independent contractor.
Company shall not enter into any contract or commitment on behalf of Client. Company further acknowledges that it is
not considered an affiliate or subsidiary of Client, and is not entitled to any Client employment rights or benefits. It is
expressly understood that this undertaking is not a joint venture.
</p>
<p>
Company recognizes and acknowledges that this Agreement creates a confidential relationship between Company and Client
and that information concerning Client's business affairs, customers, vendors, finances, properties, methods of operation, computer
programs, and documentation, and other such information, whether written, oral, or otherwise, is confidential in nature. All such
information concerning Client is hereinafter collectively referred to as "Confidential Information." Company agrees to follow
Client Information Security procedures and otherwise take all reasonable precautions for the protection of Confidential Information.
</p>
</section>
<section>
<h3>Non-Disclosure</h3>
<p>
Company agrees that, except as directed by Client, it will not at any time during or after the term of this Agreement disclose
any Confidential Information to any person whatsoever and that upon the termination of this Agreement it will turn over to Client
all documents, papers, and other matter in its possession or control that relate to Client. Company further agrees to bind its
employees and subcontractors to the terms and conditions of this Agreement.
</p>
</section>
<section>
<h3>Grant</h3>
<p>
Company agrees that its work product produced in the performance of this Agreement shall remain the exclusive property of Client, and
that it will not sell, transfer, publish, disclose or otherwise make the work product available to third parties without Client's prior
written consent. Any rights granted to Company under this Agreement shall not affect Client's exclusive ownership of the work product.
</p>
</section>
<section>
<h3>Office Rules</h3>
<p>
Company shall comply with all office rules and regulations, including security requirements, when on Client premises.
</p>
</section>
<section>
<h3>Conflict of Interest</h3>
<p>
Company shall not offer or give a gratuity of any type to any Client employee or agent.
</p>
</section>
<section>
<h3>Governing Law</h3>
<p>
This Agreement shall be construed and enforced in accordance with the laws of Governing Authority.
</p>
</section>
<section>
<h3>Entire Agreement and Notice</h3>
<p>
This Agreement contains the entire understanding of the parties and may not be amended without the specific written consent of both parties.
Any notice given under this Agreement shall be sufficient if it is in writing and if sent by certified or registered mail.
</p>
</section>
</section>
</field>
</record>

</odoo>
20 changes: 20 additions & 0 deletions website_portal_contract/demo/account_analytic_account_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 LasLabs Inc.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo>

<record id="account_analytic_account_1" model="account.analytic.account">
<field name="name">Demo Contract</field>
<field name="contract_template_id" ref="account_analytic_contract_1" />
<field name="pricelist_id" ref="product.list0" />
<field name="date_start" eval="time.strftime('%Y-%m-10')" />
<field name="recurring_next_date" eval="time.strftime('%Y-%m-20')" />
<field name="partner_id" ref="portal.demo_user0_res_partner" />
<field name="recurring_invoices" eval="True" />
<field name="website_template_id" ref="website_contract_template_default" />
<field name="recurring_invoice_line_ids"
eval="[(6, 0, [ref('account_analytic_invoice_line_1')])]" />
</record>

</odoo>
14 changes: 14 additions & 0 deletions website_portal_contract/demo/account_analytic_contract_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 LasLabs Inc.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo>

<record id="account_analytic_contract_1" model="account.analytic.contract">
<field name="name">Demo Contract Template</field>
<field name="recurring_invoicing_type">post-paid</field>
<field name="recurring_interval">10</field>
<field name="recurring_rule_type">daily</field>
</record>

</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 LasLabs Inc.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo>

<record id="account_analytic_invoice_line_1" model="account.analytic.invoice.line">
<field name="name">iPad Retina Display</field>
<field name="product_id" ref="product.product_product_4" />
<field name="quantity">10</field>
<field name="uom_id" ref="product.product_uom_unit" />
<field name="price_unit">25</field>
</record>

</odoo>
14 changes: 14 additions & 0 deletions website_portal_contract/demo/assets_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 LasLabs Inc.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->

<odoo>

<template id="assets_frontend_demo" inherit_id="website.assets_frontend">
<xpath expr=".">
<script type="text/javascript"
src="/website_portal_contract/static/src/js/tour_test_contract.js" />
</xpath>
</template>

</odoo>
7 changes: 7 additions & 0 deletions website_portal_contract/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright 2017 LasLabs Inc.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import account_analytic_account
from . import account_analytic_contract_template
from . import account_analytic_contract
Loading