From bc4d08b9b10e64b8cef9d6ba5b574571d2e1f5ff Mon Sep 17 00:00:00 2001 From: Brett Wood Date: Mon, 9 Oct 2017 08:21:24 -0700 Subject: [PATCH] [10.0][ADD] Add website_portal_contract (#62) * [ADD] Add website_portal_contract * [ADD] website_portal_contract: Add url test, usage video. * [FIX] website_portal_contract: Fix controller test. * [FIX] website_portal_contract: Change all tests to HttpCase. --- website_portal_contract/README.rst | 71 +++ website_portal_contract/__init__.py | 6 + website_portal_contract/__manifest__.py | 34 ++ .../controllers/__init__.py | 5 + website_portal_contract/controllers/main.py | 74 +++ .../data/website_contract_template_data.xml | 115 +++++ .../demo/account_analytic_account_demo.xml | 20 + .../demo/account_analytic_contract_demo.xml | 14 + .../account_analytic_invoice_line_demo.xml | 15 + website_portal_contract/demo/assets_demo.xml | 14 + website_portal_contract/models/__init__.py | 7 + .../models/account_analytic_account.py | 31 ++ .../models/account_analytic_contract.py | 24 + .../account_analytic_contract_template.py | 40 ++ .../security/ir.model.access.csv | 8 + .../static/description/icon.png | Bin 0 -> 9455 bytes .../static/src/js/tour_test_contract.js | 37 ++ website_portal_contract/tests/__init__.py | 8 + .../tests/test_account_analytic_account.py | 32 ++ .../tests/test_account_analytic_contract.py | 22 + ...test_account_analytic_contract_template.py | 21 + .../tests/test_controller.py | 37 ++ .../views/account_analytic_account_view.xml | 18 + ...ccount_analytic_contract_template_view.xml | 64 +++ .../views/account_analytic_contract_view.xml | 18 + .../website_portal_contract_templates.xml | 420 ++++++++++++++++++ 26 files changed, 1155 insertions(+) create mode 100644 website_portal_contract/README.rst create mode 100644 website_portal_contract/__init__.py create mode 100644 website_portal_contract/__manifest__.py create mode 100644 website_portal_contract/controllers/__init__.py create mode 100644 website_portal_contract/controllers/main.py create mode 100644 website_portal_contract/data/website_contract_template_data.xml create mode 100644 website_portal_contract/demo/account_analytic_account_demo.xml create mode 100644 website_portal_contract/demo/account_analytic_contract_demo.xml create mode 100644 website_portal_contract/demo/account_analytic_invoice_line_demo.xml create mode 100644 website_portal_contract/demo/assets_demo.xml create mode 100644 website_portal_contract/models/__init__.py create mode 100644 website_portal_contract/models/account_analytic_account.py create mode 100644 website_portal_contract/models/account_analytic_contract.py create mode 100644 website_portal_contract/models/account_analytic_contract_template.py create mode 100644 website_portal_contract/security/ir.model.access.csv create mode 100644 website_portal_contract/static/description/icon.png create mode 100644 website_portal_contract/static/src/js/tour_test_contract.js create mode 100644 website_portal_contract/tests/__init__.py create mode 100644 website_portal_contract/tests/test_account_analytic_account.py create mode 100644 website_portal_contract/tests/test_account_analytic_contract.py create mode 100644 website_portal_contract/tests/test_account_analytic_contract_template.py create mode 100644 website_portal_contract/tests/test_controller.py create mode 100644 website_portal_contract/views/account_analytic_account_view.xml create mode 100644 website_portal_contract/views/account_analytic_contract_template_view.xml create mode 100644 website_portal_contract/views/account_analytic_contract_view.xml create mode 100644 website_portal_contract/views/website_portal_contract_templates.xml diff --git a/website_portal_contract/README.rst b/website_portal_contract/README.rst new file mode 100644 index 00000000..ab47a2cf --- /dev/null +++ b/website_portal_contract/README.rst @@ -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 `_ + +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 +`_. 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 `_. + +Contributors +------------ + +* Brett Wood + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. diff --git a/website_portal_contract/__init__.py b/website_portal_contract/__init__.py new file mode 100644 index 00000000..23c82ff8 --- /dev/null +++ b/website_portal_contract/__init__.py @@ -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 diff --git a/website_portal_contract/__manifest__.py b/website_portal_contract/__manifest__.py new file mode 100644 index 00000000..056775ab --- /dev/null +++ b/website_portal_contract/__manifest__.py @@ -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", + ], + "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", + ], +} diff --git a/website_portal_contract/controllers/__init__.py b/website_portal_contract/controllers/__init__.py new file mode 100644 index 00000000..6d9df628 --- /dev/null +++ b/website_portal_contract/controllers/__init__.py @@ -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 diff --git a/website_portal_contract/controllers/main.py b/website_portal_contract/controllers/main.py new file mode 100644 index 00000000..23f80655 --- /dev/null +++ b/website_portal_contract/controllers/main.py @@ -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/'], + 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/" + ""], + type='http', + auth='user', + website=True, + ) + def template_view(self, contract, **kwargs): + values = {'template': contract} + return request.render( + 'website_portal_contract.website_contract_template', + values, + ) diff --git a/website_portal_contract/data/website_contract_template_data.xml b/website_portal_contract/data/website_contract_template_data.xml new file mode 100644 index 00000000..21380a3c --- /dev/null +++ b/website_portal_contract/data/website_contract_template_data.xml @@ -0,0 +1,115 @@ + + + + + + + Default Template + +
+
+

Contract

+

Disclaimer: This demo contract is not to be used for real business purposes.

+

+ 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: +

+
+
+

Compensation and Term

+

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

+

The following fees shall apply:

+

+ ..........$X per hour for services. +

+

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

+
+
+
Warranties by Company
+

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

+
+
+

Independent Contractor

+

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

+

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

+
+
+

Non-Disclosure

+

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

+
+
+

Grant

+

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

+
+
+

Office Rules

+

+ Company shall comply with all office rules and regulations, including security requirements, when on Client premises. +

+
+
+

Conflict of Interest

+

+ Company shall not offer or give a gratuity of any type to any Client employee or agent. +

+
+
+

Governing Law

+

+ This Agreement shall be construed and enforced in accordance with the laws of Governing Authority. +

+
+
+

Entire Agreement and Notice

+

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

+
+
+
+
+ +
diff --git a/website_portal_contract/demo/account_analytic_account_demo.xml b/website_portal_contract/demo/account_analytic_account_demo.xml new file mode 100644 index 00000000..23d5ac49 --- /dev/null +++ b/website_portal_contract/demo/account_analytic_account_demo.xml @@ -0,0 +1,20 @@ + + + + + + + Demo Contract + + + + + + + + + + + diff --git a/website_portal_contract/demo/account_analytic_contract_demo.xml b/website_portal_contract/demo/account_analytic_contract_demo.xml new file mode 100644 index 00000000..7c667ec5 --- /dev/null +++ b/website_portal_contract/demo/account_analytic_contract_demo.xml @@ -0,0 +1,14 @@ + + + + + + + Demo Contract Template + post-paid + 10 + daily + + + diff --git a/website_portal_contract/demo/account_analytic_invoice_line_demo.xml b/website_portal_contract/demo/account_analytic_invoice_line_demo.xml new file mode 100644 index 00000000..134013d9 --- /dev/null +++ b/website_portal_contract/demo/account_analytic_invoice_line_demo.xml @@ -0,0 +1,15 @@ + + + + + + + iPad Retina Display + + 10 + + 25 + + + diff --git a/website_portal_contract/demo/assets_demo.xml b/website_portal_contract/demo/assets_demo.xml new file mode 100644 index 00000000..c9512738 --- /dev/null +++ b/website_portal_contract/demo/assets_demo.xml @@ -0,0 +1,14 @@ + + + + + +