[MOV] (website_portal_)purchase: move customer portal to purchase
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import controllers
|
||||
from . import models
|
||||
from . import report
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
'data/mail_template_data.xml',
|
||||
'views/purchase_config_settings_views.xml',
|
||||
'views/account_config_settings_views.xml',
|
||||
'views/portal_templates.xml',
|
||||
'report/purchase_order_templates.xml',
|
||||
'report/purchase_quotation_templates.xml',
|
||||
],
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import purchase
|
||||
from . import portal
|
||||
+7
-7
@@ -8,13 +8,13 @@ from odoo.exceptions import AccessError
|
||||
from odoo.http import request
|
||||
from odoo.tools import pycompat
|
||||
from odoo.tools.translate import _
|
||||
from odoo.addons.portal.controllers.portal import get_records_pager, CustomerPortal
|
||||
from odoo.addons.portal.controllers.portal import get_records_pager, pager as portal_pager, CustomerPortal
|
||||
|
||||
|
||||
class WebsitePortal(CustomerPortal):
|
||||
class CustomerPortal(CustomerPortal):
|
||||
|
||||
def _prepare_portal_layout_values(self):
|
||||
values = super(WebsitePortal, self)._prepare_portal_layout_values()
|
||||
values = super(CustomerPortal, self)._prepare_portal_layout_values()
|
||||
partner = request.env.user.partner_id
|
||||
values['purchase_count'] = request.env['purchase.order'].search_count([
|
||||
'|',
|
||||
@@ -64,7 +64,7 @@ class WebsitePortal(CustomerPortal):
|
||||
# count for pager
|
||||
purchase_count = PurchaseOrder.search_count(domain)
|
||||
# make pager
|
||||
pager = request.website.pager(
|
||||
pager = portal_pager(
|
||||
url="/my/purchase",
|
||||
url_args={'date_begin': date_begin, 'date_end': date_end},
|
||||
total=purchase_count,
|
||||
@@ -92,7 +92,7 @@ class WebsitePortal(CustomerPortal):
|
||||
'filterby': filterby,
|
||||
'default_url': '/my/purchase',
|
||||
})
|
||||
return request.render("website_portal_purchase.portal_my_purchase_orders", values)
|
||||
return request.render("purchase.portal_my_purchase_orders", values)
|
||||
|
||||
@http.route(['/my/purchase/<int:order_id>'], type='http', auth="user", website=True)
|
||||
def portal_my_purchase_order(self, order_id=None, **kw):
|
||||
@@ -101,10 +101,10 @@ class WebsitePortal(CustomerPortal):
|
||||
order.check_access_rights('read')
|
||||
order.check_access_rule('read')
|
||||
except AccessError:
|
||||
return request.render("website.403")
|
||||
return request.redirect('/my')
|
||||
history = request.session.get('my_purchases_history', [])
|
||||
values = {
|
||||
'order': order.sudo(),
|
||||
}
|
||||
values.update(get_records_pager(history, order))
|
||||
return request.render("website_portal_purchase.portal_my_purchase_order", values)
|
||||
return request.render("purchase.portal_my_purchase_order", values)
|
||||
@@ -163,6 +163,14 @@ class PurchaseOrder(models.Model):
|
||||
group_id = fields.Many2one('procurement.group', string="Procurement Group", copy=False)
|
||||
is_shipped = fields.Boolean(compute="_compute_is_shipped")
|
||||
|
||||
website_url = fields.Char(
|
||||
'Website URL', compute='_website_url',
|
||||
help='The full URL to access the document through the website.')
|
||||
|
||||
def _website_url(self):
|
||||
for order in self:
|
||||
order.website_url = '/my/purchase/%s' % (order.id)
|
||||
|
||||
@api.model
|
||||
def name_search(self, name, args=None, operator='ilike', limit=100):
|
||||
args = args or []
|
||||
@@ -595,6 +603,9 @@ class PurchaseOrderLine(models.Model):
|
||||
taxes_id = fields.Many2many('account.tax', string='Taxes', domain=['|', ('active', '=', False), ('active', '=', True)])
|
||||
product_uom = fields.Many2one('product.uom', string='Product Unit of Measure', required=True)
|
||||
product_id = fields.Many2one('product.product', string='Product', domain=[('purchase_ok', '=', True)], change_default=True, required=True)
|
||||
product_image = fields.Binary(
|
||||
'Product Image', related="product_id.image",
|
||||
help="Non-stored related field to allow portal user to see the image of the product he has ordered")
|
||||
move_ids = fields.One2many('stock.move', 'purchase_line_id', string='Reservation', readonly=True, ondelete='set null', copy=False)
|
||||
price_unit = fields.Float(string='Unit Price', required=True, digits=dp.get_precision('Product Price'))
|
||||
|
||||
|
||||
@@ -3,10 +3,12 @@ access_purchase_order,purchase.order,model_purchase_order,group_purchase_user,1,
|
||||
access_purchase_order_manager,purchase.order,model_purchase_order,group_purchase_manager,1,1,1,1
|
||||
access_purchase_order_stock_worker,purchase.order,model_purchase_order,stock.group_stock_user,1,0,0,0
|
||||
access_purchase_order_invoicing_payments,purchase.order,model_purchase_order,account.group_account_invoice,1,1,0,0
|
||||
access_purchase_order_portal,purchase.order.portal,purchase.model_purchase_order,base.group_portal,1,0,0,0
|
||||
access_purchase_order_line,purchase.order.line user,model_purchase_order_line,group_purchase_user,1,1,1,1
|
||||
access_purchase_order_line_manager,purchase.order.line,model_purchase_order_line,group_purchase_manager,1,1,1,1
|
||||
access_purchase_order_line_stock_worker,purchase.order.line,model_purchase_order_line,stock.group_stock_user,1,0,0,0
|
||||
access_purchase_order_line_invoicing_payments,purchase.order.line,model_purchase_order_line,account.group_account_invoice,1,1,0,0
|
||||
access_purchase_order_line_portal,purchase.order.line.portal,purchase.model_purchase_order_line,base.group_portal,1,0,0,0
|
||||
access_stock_location_purchase_user,stock.location,stock.model_stock_location,group_purchase_user,1,0,0,0
|
||||
access_stock_warehouse_purchase_user,stock.warehouse,stock.model_stock_warehouse,group_purchase_user,1,0,0,0
|
||||
access_stock_picking_purchase_user,stock.picking,stock.model_stock_picking,group_purchase_user,1,1,1,1
|
||||
|
||||
|
@@ -51,5 +51,22 @@
|
||||
<field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
|
||||
</record>
|
||||
|
||||
<record id="portal_purchase_order_user_rule" model="ir.rule">
|
||||
<field name="name">Portal Purchase Orders</field>
|
||||
<field name="model_id" ref="purchase.model_purchase_order"/>
|
||||
<field name="domain_force">[('message_partner_ids','child_of',[user.commercial_partner_id.id])]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_portal'))]"/>
|
||||
<field name="perm_unlink" eval="1"/>
|
||||
<field name="perm_write" eval="1"/>
|
||||
<field name="perm_read" eval="1"/>
|
||||
<field name="perm_create" eval="0"/>
|
||||
</record>
|
||||
|
||||
<record id="portal_purchase_order_line_rule" model="ir.rule">
|
||||
<field name="name">Portal Purhcase Orders Line</field>
|
||||
<field name="model_id" ref="purchase.model_purchase_order_line"/>
|
||||
<field name="domain_force">[('order_id.message_partner_ids','child_of',[user.commercial_partner_id.id])]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_portal'))]"/>
|
||||
</record>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@
|
||||
</t>
|
||||
</table></div>
|
||||
<div t-if="pager" class="o_portal_pager text-center">
|
||||
<t t-call="website.pager"/>
|
||||
<t t-call="portal.pager"/>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
@@ -1,5 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import controllers
|
||||
from . import models
|
||||
|
||||
@@ -15,9 +15,6 @@ Display purchase orders on your website. Customers will be able to access their
|
||||
'portal',
|
||||
],
|
||||
'data': [
|
||||
'views/website_portal_purchase_templates.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/website_portal_purchase_security.xml',
|
||||
],
|
||||
'installable': True,
|
||||
}
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import website_portal
|
||||
@@ -1,23 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class PurchaseOrder(models.Model):
|
||||
|
||||
_inherit = 'purchase.order'
|
||||
|
||||
website_url = fields.Char('Website URL', compute='_website_url', help='The full URL to access the document through the website.')
|
||||
|
||||
def _website_url(self):
|
||||
for order in self:
|
||||
order.website_url = '/my/purchase/%s' % (order.id)
|
||||
|
||||
|
||||
class PurchaseOrderLine(models.Model):
|
||||
|
||||
_inherit = 'purchase.order.line'
|
||||
|
||||
# Non-stored related field to allow portal user to see the image of the product he has ordered
|
||||
product_image = fields.Binary('Product Image', related="product_id.image")
|
||||
@@ -1,3 +0,0 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_purchase_order_portal,purchase.order.portal,purchase.model_purchase_order,base.group_portal,1,0,0,0
|
||||
access_purchase_order_line_portal,purchase.order.line.portal,purchase.model_purchase_order_line,base.group_portal,1,0,0,0
|
||||
|
@@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
|
||||
<record id="portal_purchase_order_user_rule" model="ir.rule">
|
||||
<field name="name">Portal Purchase Orders</field>
|
||||
<field name="model_id" ref="purchase.model_purchase_order"/>
|
||||
<field name="domain_force">[('message_partner_ids','child_of',[user.commercial_partner_id.id])]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_portal'))]"/>
|
||||
<field name="perm_unlink" eval="1"/>
|
||||
<field name="perm_write" eval="1"/>
|
||||
<field name="perm_read" eval="1"/>
|
||||
<field name="perm_create" eval="0"/>
|
||||
</record>
|
||||
|
||||
<record id="portal_purchase_order_line_rule" model="ir.rule">
|
||||
<field name="name">Portal Purhcase Orders Line</field>
|
||||
<field name="model_id" ref="purchase.model_purchase_order_line"/>
|
||||
<field name="domain_force">[('order_id.message_partner_ids','child_of',[user.commercial_partner_id.id])]</field>
|
||||
<field name="groups" eval="[(4, ref('base.group_portal'))]"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user