Skip to content

Commit

Permalink
[MIG] Migrate website_sale_multic_ux to 16.0
Browse files Browse the repository at this point in the history
[ADD] Add new module website_multicompany
[ADD] Add new module website_sale_multicompany
  • Loading branch information
maq-adhoc committed May 15, 2023
1 parent 3d30146 commit 5125b64
Show file tree
Hide file tree
Showing 13 changed files with 311 additions and 4 deletions.
7 changes: 5 additions & 2 deletions payment_multic_ux/models/account_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ class AccountPayment(models.Model):
def create(self, val_list):
force_company = self.env.context.get('force_company_id')
if force_company:
for vals in val_list:
vals['company_id'] = force_company
if isinstance(val_list, list):
for vals in val_list:
vals['company_id'] = force_company
else:
val_list['company_id'] = force_company
return super().create(val_list)
74 changes: 74 additions & 0 deletions website_multicompany/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
.. |company| replace:: ADHOC SA

.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png
:alt: ADHOC SA
:target: https://www.adhoc.com.ar

.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png

.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

==============================
Website Multicompany
==============================

# This module allows portal users to view their records of the companies they have assigned as allowed companies (company_ids). By default Odoo usually allows to see only the company of the website.
# By installing this module automatically on the whole website users will see records of the company_ids they have assigned.

# Este modulo es para que usuarios portal vean registros de las compañías que tienen asignadas como compañías permitidas (company_ids). Por defecto Odoo suele dejar ver solo lo de la compañía del sitio web.
# Al instalar este módulo automáticamente en todo el sitio web los usuarios van a ver registros de las company_ids que tengan asignadas.

Installation
============

To install this module, you need to:

#. Only install the module

Configuration
=============

To configure this module, you need to:

#. Go to a Payment acquirer and select a journal that belongs to a different company than the Payment method

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: http://runbot.adhoc.com.ar/

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/ingadhoc/multi-company/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: http://runbot.adhoc.com.ar/


* |company| |icon|

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

Maintainer
----------

|company_logo|

This module is maintained by the |company|.

To contribute to this module, please visit https://www.adhoc.com.ar.

Este modulo es para que usuarios portal vean registros de las compañías que tienen asignadas como compañías permitidas (company_ids). Por defecto Odoo suele dejar ver solo lo de la compañía del sitio web.
1 change: 1 addition & 0 deletions website_multicompany/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
33 changes: 33 additions & 0 deletions website_multicompany/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
##############################################################################
#
# Copyright (C) 2023 ADHOC SA (http://www.adhoc.com.ar)
# All Rights Reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Website Multicompany',
'version': "16.0.1.0.0",
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'depends': [
'website',
],
'data': [],
'demo': [],
'installable': True,
'auto_install': False,
}
1 change: 1 addition & 0 deletions website_multicompany/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import website
33 changes: 33 additions & 0 deletions website_multicompany/models/website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################

import logging
from odoo import models, tools
from odoo.http import request

class Http(models.AbstractModel):
_inherit = 'ir.http'

@classmethod
def _frontend_pre_dispatch(cls):
super()._frontend_pre_dispatch()
user = request.env.user
website = request.env['website'].get_current_website()

if user.id != website._get_cached('user_id'):
users_company_ids = website._get_cached_companies()
request.update_context(
allowed_company_ids=users_company_ids,
)
request.website = website.with_context(request.context)

class Website(models.Model):

_inherit = 'website'

@tools.ormcache('self.env.uid')
def _get_cached_companies(self):
return self.env.user.company_ids.ids

4 changes: 2 additions & 2 deletions website_sale_multic_ux/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Website Sale Multicompany Usability',
'version': "15.0.1.1.0",
'version': "16.0.1.0.0",
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
Expand All @@ -29,6 +29,6 @@
],
'data': [],
'demo': [],
'installable': False,
'installable': True,
'auto_install': False,
}
71 changes: 71 additions & 0 deletions website_sale_multicompany/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.. |company| replace:: ADHOC SA

.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png
:alt: ADHOC SA
:target: https://www.adhoc.com.ar

.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png

.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

==============================
Website Sale Multicompany
==============================

# Con este modulo, cuando un usuario hace una compra en sitio web la misma se hará en la compañía por defecto que tenga seteada el usuario (company_id) en vez de la compañía del sitio web. Los métodos de envío y pago que se mostrarán serán lo de la compañía de la orden.

Installation
============

To install this module, you need to:

#. Only install the module

Configuration
=============

To configure this module, you need to:

#. Go to a Payment acquirer and select a journal that belongs to a different company than the Payment method

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: http://runbot.adhoc.com.ar/

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/ingadhoc/multi-company/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: http://runbot.adhoc.com.ar/


* |company| |icon|
* Eficent |iconEficent| Part of the code used for this module was extracted from Eficent's `multicompany-fixes/mcfix_accpount <https://github.com/Eficent/multicompany-fixes/tree/11.0/mcfix_account>`_ module

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

Maintainer
----------

|company_logo|

This module is maintained by the |company|.

To contribute to this module, please visit https://www.adhoc.com.ar.

Este modulo es para que usuarios portal vean registros de las compañías que tienen asignadas como compañías permitidas (company_ids). Por defecto Odoo suele dejar ver solo lo de la compañía del sitio web.
1 change: 1 addition & 0 deletions website_sale_multicompany/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
34 changes: 34 additions & 0 deletions website_sale_multicompany/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
##############################################################################
#
# Copyright (C) 2023 ADHOC SA (http://www.adhoc.com.ar)
# All Rights Reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'Website Sale multicompany',
'version': "16.0.1.0.0",
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'depends': [
'website_sale_stock',
'website_multicompany',
],
'data': [],
'demo': [],
'installable': True,
'auto_install': False,
}
2 changes: 2 additions & 0 deletions website_sale_multicompany/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import website
from . import sale_order
26 changes: 26 additions & 0 deletions website_sale_multicompany/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################

from odoo import models, fields


class SaleOrder(models.Model):

_inherit = 'sale.order'

analytic_account_id = fields.Many2one(
check_company=False, # Unrequired company
)

def _get_warehouse_available(self):
self.ensure_one()
warehouse = self.website_id._get_warehouse_available()
if warehouse.company_id != self.company_id:
return (
self.env['ir.default'].get('sale.order', 'warehouse_id', company_id=self.company_id.id) or
self.env['stock.warehouse'].sudo().search([('company_id', '=', self.company_id.id)], limit=1).id
)

return super()._get_warehouse_available()
28 changes: 28 additions & 0 deletions website_sale_multicompany/models/website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################

import logging
from odoo import models, tools
from odoo.http import request


class Website(models.Model):

_inherit = 'website'


def sale_get_order(self, force_create=False, update_pricelist=False):
sale_order_sudo = super().sale_get_order(force_create, update_pricelist)
vals = {}
if sale_order_sudo.company_id != self.env.user.company_id:
vals['company_id'] = self.env.user.company_id.id
if hasattr(sale_order_sudo, 'warehouse_id') and sale_order_sudo.warehouse_id.company_id != self.env.user.company_id:
vals['warehouse_id'] = (
self.env['ir.default'].get('sale.order', 'warehouse_id', company_id=self.env.user.company_id.id) or
self.env['stock.warehouse'].sudo().search([('company_id', '=', self.env.user.company_id.id)], limit=1).id
)
if vals:
sale_order_sudo.write(vals)
return sale_order_sudo

0 comments on commit 5125b64

Please sign in to comment.