Skip to content

Commit

Permalink
Merge 45a5150 into 5c625bc
Browse files Browse the repository at this point in the history
  • Loading branch information
LeartS committed Oct 30, 2015
2 parents 5c625bc + 45a5150 commit dc1b5be
Show file tree
Hide file tree
Showing 11 changed files with 576 additions and 0 deletions.
45 changes: 45 additions & 0 deletions website_portal_sale/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
========================
Website Portal for Sales
========================

Backport (with adjustments) of the ``website_portal_sale`` module of Odoo 9.

This module add the user's sales documents in the frontend portal.
Customers will be able to see the list and state of their quotations, sales
and invoices.

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

* In v9, the field ``validity_date`` of the sale order has been moved from the
``website_quote`` module to the base ``sale`` module, therefore the module
references it without problem as the ``sale`` module is a dependency of this
one.
For version 8 the validity_date on the portal has been removed completely at
the moment. Instead, we should make a conditional template that shows the field
if the ``website_quote`` module is installed.
* Tests

Credits
=======

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

* Odoo SA <https://www.odoo.com>
* Leonardo Donelli @ MONK Software <donelli@webmonks.it>

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 http://odoo-community.org.
1 change: 1 addition & 0 deletions website_portal_sale/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import controllers
24 changes: 24 additions & 0 deletions website_portal_sale/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
'name': 'Website Portal for Sales',
'category': 'Website',
'summary': (
'Add your sales document in the frontend portal (sales order'
', quotations, invoices)'
),
'version': '1.0',
'author': 'Odoo SA, MONK Software',
'website': 'https://www.odoo.com/, http://www.wearemonk.com',
'depends': [
'sale',
'website_portal',
],
'data': [
'templates/website_portal_sale.xml',
'templates/website_portal.xml',
'templates/website.xml',
],
'demo': [
'demo/sale_order.xml',
],
'installable': True,
}
1 change: 1 addition & 0 deletions website_portal_sale/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import main
59 changes: 59 additions & 0 deletions website_portal_sale/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
import datetime

from openerp import http
from openerp.http import request

from openerp.addons.website_portal.controllers.main import WebsiteAccount


class PortalSaleWebsiteAccount(WebsiteAccount):

@http.route(['/my/home'], type='http', auth="user", website=True)
def account(self, **kw):
""" Add sales documents to main account page """
response = super(PortalSaleWebsiteAccount, self).account(**kw)

partner = request.env.user.partner_id
quotations = request.env['sale.order'].search([
('partner_id.id', '=', partner.id),
('state', 'in', ['sent', 'cancel'])
])
orders = request.env['sale.order'].search([
('partner_id.id', '=', partner.id),
('state', 'in', ['progress', 'manual', 'shipping_except',
'invoice_except', 'done'])
])
invoices = request.env['account.invoice'].search([
('partner_id.id', '=', partner.id),
('state', 'in', ['open', 'paid', 'cancelled'])
])

response.qcontext.update({
'date': datetime.date.today().strftime('%Y-%m-%d'),
'quotations': quotations,
'orders': orders,
'invoices': invoices,
})
return response

@http.route(['/my/orders/<int:order>'], type='http', auth="user",
website=True)
def orders_followup(self, order=None):
partner = request.env['res.users'].browse(request.uid).partner_id
domain = [
('partner_id.id', '=', partner.id),
('state', 'not in', ['draft', 'cancel']),
('id', '=', order)
]
order = request.env['sale.order'].search(domain)
invoiced_lines = request.env['account.invoice.line'].search([
('invoice_id', 'in', order.invoice_ids.ids)
])
order_invoice_lines = {il.product_id.id: il.invoice_id
for il in invoiced_lines}

return request.website.render("website_portal_sale.orders_followup", {
'order': order.sudo(),
'order_invoice_lines': order_invoice_lines,
})
84 changes: 84 additions & 0 deletions website_portal_sale/demo/sale_order.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record id="sale_order_1" model="sale.order">
<field name="partner_id" ref="portal.partner_demo_portal"/>
<field name="partner_invoice_id" ref="portal.partner_demo_portal"/>
<field name="partner_shipping_id" ref="portal.partner_demo_portal"/>
<field name="user_id" ref="base.user_root"/>
<field name="pricelist_id" ref="product.list0"/>
<field name="state">sent</field>
<field name="section_id" ref="sales_team.section_sales_department"/>
<field name="date_order" eval="(DateTime.today() - relativedelta(months=1)).strftime('%Y-%m-%d %H:%M')"/>
<field name="message_follower_ids" eval="[(4, ref('portal.partner_demo_portal'))]"/>
</record>

<record id="sale_order_line_1" model="sale.order.line">
<field name="order_id" ref="sale_order_1"/>
<field name="name">Laptop E5023</field>
<field name="product_id" ref="product.product_product_25"/>
<field name="product_uom_qty">3</field>
<field name="product_uos_qty">3</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">2950.00</field>
</record>

<record id="sale_order_line_2" model="sale.order.line">
<field name="order_id" ref="sale_order_1"/>
<field name="name">Pen drive, 16GB</field>
<field name="product_id" ref="product.product_product_30"/>
<field name="product_uom_qty">5</field>
<field name="product_uos_qty">5</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">145.00</field>
</record>

<record id="sale_order_line_3" model="sale.order.line">
<field name="order_id" ref="sale_order_1"/>
<field name="name">Headset USB</field>
<field name="product_id" ref="product.product_product_33"/>
<field name="product_uom_qty">2</field>
<field name="product_uos_qty">2</field>
<field name="product_uom" ref="product.product_uom_unit"/>
<field name="price_unit">65.00</field>
</record>

<record id="sale_order_2" model="sale.order">
<field name="partner_id" ref="portal.partner_demo_portal"/>
<field name="partner_invoice_id" ref="portal.partner_demo_portal"/>
<field name="partner_shipping_id" ref="portal.partner_demo_portal"/>
<field name="user_id" ref="base.user_root"/>
<field name="pricelist_id" ref="product.list0"/>
<field name="order_policy">manual</field>
<field name="section_id" ref="sales_team.section_sales_department"/>
<field name="date_order" eval="(DateTime.today() - relativedelta(months=1)).strftime('%Y-%m-%d %H:%M')"/>
<field name="message_follower_ids" eval="[(4, ref('portal.partner_demo_portal'))]"/>
</record>

<record id="sale_order_line_4" model="sale.order.line">
<field name="order_id" ref="sale_order_2"/>
<field name="name">Service on demand</field>
<field name="product_id" ref="product.product_product_1"/>
<field name="product_uom_qty">24</field>
<field name="product_uos_qty">24</field>
<field name="product_uom" ref="product.product_uom_hour"/>
<field name="price_unit">75.00</field>
</record>

<record id="sale_order_line_5" model="sale.order.line">
<field name="order_id" ref="sale_order_2"/>
<field name="name">On Site Assistance</field>
<field name="product_id" ref="product.product_product_2"/>
<field name="product_uom_qty">30</field>
<field name="product_uos_qty">30</field>
<field name="product_uom" ref="product.product_uom_hour"/>
<field name="price_unit">38.25</field>
</record>


<!-- Confirm some Sale Orders-->
<workflow action="order_confirm" model="sale.order" ref="sale_order_2"/>

</data>
</openerp>
14 changes: 14 additions & 0 deletions website_portal_sale/static/src/js/website_portal_sale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(function() {
'use strict';

openerp.website.if_dom_contains('.o_my_show_more', function() {

$('.o_my_show_more').on('click', function(ev) {
ev.preventDefault();
$(this).parents('table').find(".to_hide").toggleClass('hidden');
$(this).find('span').toggleClass('hidden');
});

});

}());
11 changes: 11 additions & 0 deletions website_portal_sale/static/src/less/website_portal_sale.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* ---- My Orders page ---- */

.orders_vertical_align {
display: flex;
align-items: center;
}


.orders_label_text_align {
vertical-align: 15%;
}
13 changes: 13 additions & 0 deletions website_portal_sale/templates/website.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<template id="assets_frontend" inherit_id="website.assets_frontend" name="Website Portal Sale">
<xpath expr="." position="inside">
<link rel='stylesheet' href='/website_portal_sale/static/src/less/website_portal_sale.less'/>
<script type="text/javascript" src="/website_portal_sale/static/src/js/website_portal_sale.js"></script>
</xpath>
</template>

</data>
</openerp>
14 changes: 14 additions & 0 deletions website_portal_sale/templates/website_portal.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<template id="account" name="Account" inherit_id="website_portal.account">
<xpath expr="//div[contains(@class,'o_my_documents')]" position="inside">
<t t-call="website_portal_sale.quotations" />
<t t-call="website_portal_sale.sale_orders" />
<t t-call="website_portal_sale.invoices" />
</xpath>
</template>

</data>
</openerp>

0 comments on commit dc1b5be

Please sign in to comment.