Skip to content

Commit

Permalink
[MIG] portal_sale_distributor: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vib-adhoc committed Jun 22, 2023
1 parent 8565d80 commit 0b1baf3
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 162 deletions.
7 changes: 4 additions & 3 deletions portal_sale_distributor/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Portal Distributor Sale',
'version': "15.0.1.0.0",
'version': "16.0.1.0.0",
'category': 'Tools',
'complexity': 'easy',
'author': 'ADHOC SA, Odoo Community Association (OCA)',
Expand All @@ -34,6 +34,7 @@
'portal_backend',
],
'demo': [
'demo/res_users_demo.xml',
],
'data': [
'security/portal_sale_distributor_security.xml',
Expand All @@ -42,9 +43,9 @@
'views/portal_my_account_views.xml',
'views/product_product_views.xml',
'views/product_template_views.xml',
'views/portal_templates.xml',
# 'views/portal_templates.xml',
'views/sale_report_templates.xml',
],
'installable': False,
'installable': True,
'auto_install': False,
}
68 changes: 7 additions & 61 deletions portal_sale_distributor/controllers/portal_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,25 @@
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from odoo import http, _
from odoo import _
from odoo.addons.account.controllers.portal import PortalAccount
from odoo.addons.portal.controllers.portal import pager as portal_pager
from odoo.http import request
from collections import OrderedDict


class PortalDistributorAccount(PortalAccount):

def _get_account_invoice_domain(self):
def _get_invoice_domain(self):
partner = request.env.user.partner_id
domain = [('move_type', 'in', ['out_invoice', 'out_refund']),
('message_partner_ids', 'child_of',
[partner.commercial_partner_id.id]),
('state', 'in', ['posted', 'cancel'])]
return domain

@http.route()
def portal_my_invoices(
self, page=1, date_begin=None, date_end=None, sortby=None,
filterby=None, **kw):
values = self._prepare_portal_layout_values()
AccountInvoice = request.env['account.move']

domain = self._get_account_invoice_domain()
searchbar_filters = {
def _get_account_searchbar_filters(self):
return {
'all': {'label': _('All'), 'domain': []},
'open': {'label': _('Open'),
'domain': [('state', '=', 'posted'), ('payment_state', '=', 'not_paid')]},
}

searchbar_sortings = {
'date': {'label': _('Invoice Date'), 'order': 'invoice_date desc'},
'duedate': {'label': _('Due Date'), 'order': 'invoice_date_due desc'},
'name': {'label': _('Reference'), 'order': 'name desc'},
'state': {'label': _('Status'), 'order': 'state'},
'invoices': {'label': _('Invoices'), 'domain': [('move_type', '=', ('out_invoice', 'out_refund'))]},
'bills': {'label': _('Bills'), 'domain': [('move_type', '=', ('in_invoice', 'in_refund'))]},
'open': {'label': _('Open'), 'domain': [('state', '=', 'posted'), ('payment_state', '=', 'not_paid')]},
}
# default sort by order
if not sortby:
sortby = 'date'
order = searchbar_sortings[sortby]['order']
if not filterby:
filterby = 'all'
domain += searchbar_filters[filterby]['domain']

archive_groups = self._get_archive_groups('account.move', domain)
if date_begin and date_end:
domain += [('create_date', '>', date_begin),
('create_date', '<=', date_end)]

# count for pager
invoice_count = AccountInvoice.search_count(domain)
# pager
pager = portal_pager(
url="/my/invoices",
url_args={'date_begin': date_begin, 'date_end': date_end,
'sortby': sortby, 'filterby': filterby},
total=invoice_count, page=page, step=self._items_per_page)
# content according to pager and archive selected
invoices = AccountInvoice.search(
domain, order=order, limit=self._items_per_page,
offset=pager['offset'])
values.update({
'date': date_begin,
'invoices': invoices,
'page_name': 'invoice',
'pager': pager,
'archive_groups': archive_groups,
'default_url': '/my/invoices',
'searchbar_sortings': searchbar_sortings,
'searchbar_filters': OrderedDict(
sorted(searchbar_filters.items())),
'sortby': sortby,
'filterby': filterby,
})
return request.render("account.portal_my_invoices", values)
6 changes: 6 additions & 0 deletions portal_sale_distributor/demo/res_users_demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<odoo>
<record id="portal_backend.user_portal_advanced" model="res.users" context="{'no_reset_password': True}">
<field name="groups_id" eval="[(4, ref('portal_sale_distributor.group_portal_backend_distributor'))]"/>
</record>
</odoo>
2 changes: 1 addition & 1 deletion portal_sale_distributor/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ msgid "Pedido confirmado por %s"
msgstr ""

#. module: portal_sale_distributor
#: model:res.groups,name:portal_sale_distributor.group_portal_distributor
#: model:res.groups,name:portal_sale_distributor.group_portal_backend_distributor
msgid "Portal - Distributor"
msgstr "Portal - Wiederverkäufer"

Expand Down
2 changes: 1 addition & 1 deletion portal_sale_distributor/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ msgid "Pedido confirmado por %s"
msgstr "Pedido confirmado por %s"

#. module: portal_sale_distributor
#: model:res.groups,name:portal_sale_distributor.group_portal_distributor
#: model:res.groups,name:portal_sale_distributor.group_portal_backend_distributor
msgid "Portal - Distributor"
msgstr "Portal - Distributor"

Expand Down
2 changes: 1 addition & 1 deletion portal_sale_distributor/i18n/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ msgid "Pedido confirmado por %s"
msgstr ""

#. module: portal_sale_distributor
#: model:res.groups,name:portal_sale_distributor.group_portal_distributor
#: model:res.groups,name:portal_sale_distributor.group_portal_backend_distributor
msgid "Portal - Distributor"
msgstr "Портал - Дистрибьютор"

Expand Down
2 changes: 1 addition & 1 deletion portal_sale_distributor/migrations/12.0.1.0.0/mig_data.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<odoo noupdate="1">
<record id="group_portal_distributor" model="res.groups">
<record id="group_portal_backend_distributor" model="res.groups">
<field name="category_id" ref="base.module_category_user_type"/>
</record>
</odoo>
2 changes: 1 addition & 1 deletion portal_sale_distributor/models/mail_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class MailThread(models.AbstractModel):

def _message_auto_subscribe(self, updated_values, followers_existing_policy='skip'):
""" Cuando usuario portal crea OV se manda un mensjae de suscripcion
al comercial, esto terminahaciendo que se arroje error si se tiene
al comercial, esto termina haciendo que se arroje error si se tiene
instalado mass_mailing y las estadisticas por permiso de acceso
a estadisticas. De esta forma lo arreglamos para que no haga falta
modulo puente
Expand Down
26 changes: 24 additions & 2 deletions portal_sale_distributor/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
# directory
##############################################################################
from odoo import models, fields, api, _
import json


class SaleOrder(models.Model):
_inherit = 'sale.order'

activity_date_deadline = fields.Date(
groups="base.group_user,"
"portal_sale_distributor.group_portal_distributor"
"portal_sale_distributor.group_portal_backend_distributor"
)

def action_confirm_distributor(self):
Expand All @@ -25,7 +26,28 @@ def _onchange_partner_id_warning(self):
""" desactivamos warning para portal distributor
"""
if self.env.user.has_group(
'portal_sale_distributor.group_portal_distributor'):
'portal_sale_distributor.group_portal_backend_distributor'):
return {}
else:
return super()._onchange_partner_id_warning()

@api.model
def _get_view(self, view_id=None, view_type='form', **options):
arch, view = super()._get_view(view_id, view_type, **options)
if view_type == 'form':
if self.env.user.has_group('portal_sale_distributor.group_portal_backend_distributor'):
fields = (arch.xpath("//field[@name='partner_id']")
+ arch.xpath("//field[@name='partner_invoice_id']")
+ arch.xpath("//field[@name='partner_shipping_id']")
)
for node in fields:
node.set('options', "{'no_create': True, 'no_open': True}")

# ocultamos pestaña otra información
page = arch.xpath("//page[@name='other_information']")
for node in page:
node.set('invisible', '1')
modifiers = json.loads(node.get("modifiers") or "{}")
modifiers['invisible'] = True
node.set("modifiers", json.dumps(modifiers))
return arch, view

0 comments on commit 0b1baf3

Please sign in to comment.