diff --git a/ext/3rd-party-addons/website_multi_company_sale/README.rst b/ext/3rd-party-addons/website_multi_company_sale/README.rst new file mode 100644 index 00000000..73b098da --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/README.rst @@ -0,0 +1,45 @@ +========================================== + Real Multi Website (eCommerce extension) +========================================== + +Multi Website support in eCommerce: + +* adds field ``website_ids`` to payment.acquirer +* adds field ``website_ids`` to product.template +* adds field ``website_ids`` to product.public.category +* use separate sale order (cart) for different companies -- works by adding ``company_dependent`` attribute to ``last_website_so_id`` field + + +Credits +======= + +Contributors +------------ +* `Ivan Yelizariev `__ + +Sponsors +-------- +* `IT-Projects LLC `__ + +Maintainers +----------- +* `IT-Projects LLC `__ + + To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store `__. + + Thank you for understanding! + + `IT-Projects Team `__ + +Further information +=================== + +Demo: http://runbot.it-projects.info/demo/website-addons/11.0 + +HTML Description: https://apps.odoo.com/apps/modules/11.0/website_multi_company_sale/ + +Usage instructions: ``_ + +Changelog: ``_ + +Tested on Odoo 11.0 f34d4d33a09d33a12e427c2490b6526546114486 diff --git a/ext/3rd-party-addons/website_multi_company_sale/__init__.py b/ext/3rd-party-addons/website_multi_company_sale/__init__.py new file mode 100644 index 00000000..f7209b17 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import controllers diff --git a/ext/3rd-party-addons/website_multi_company_sale/__manifest__.py b/ext/3rd-party-addons/website_multi_company_sale/__manifest__.py new file mode 100644 index 00000000..82cdb1da --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/__manifest__.py @@ -0,0 +1,42 @@ +{ + "name": """Real Multi Website (eCommerce extension)""", + "summary": """Multi Website support in eCommerce""", + "category": "eCommerce", + "live_test_url": "http://apps.it-projects.info/shop/product/website-multi-company?version=11.0", + "images": ["images/website_multi_company_sale_main.png"], + "version": "11.0.1.2.0", + "application": False, + + "author": "IT-Projects LLC, Ivan Yelizariev", + "support": "apps@it-projects.info", + "website": "https://it-projects.info/team/yelizariev", + "license": "LGPL-3", + "price": 9.00, + "currency": "EUR", + + "depends": [ + "website_multi_company", + "website_sale", + "ir_rule_website", + ], + "external_dependencies": {"python": [], "bin": []}, + "data": [ + "views/product_public_category_views.xml", + "views/website_views.xml", + "views/product_template_views.xml", + "views/payment_views.xml", + "security/website_multi_company_sale_security.xml", + ], + "qweb": [ + ], + "demo": [ + ], + + "post_load": None, + "pre_init_hook": None, + "post_init_hook": None, + "uninstall_hook": None, + + "auto_install": False, + "installable": True, +} diff --git a/ext/3rd-party-addons/website_multi_company_sale/controllers/__init__.py b/ext/3rd-party-addons/website_multi_company_sale/controllers/__init__.py new file mode 100644 index 00000000..12a7e529 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/ext/3rd-party-addons/website_multi_company_sale/controllers/main.py b/ext/3rd-party-addons/website_multi_company_sale/controllers/main.py new file mode 100644 index 00000000..9aaff502 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/controllers/main.py @@ -0,0 +1,19 @@ +from odoo import http +from odoo.http import request +from odoo.addons.website_sale.controllers.main import WebsiteSale + + +class WebsiteMultiCompanySale(WebsiteSale): + @http.route() + def shop(self, page=0, category=None, search='', ppg=False, **post): + response = super(WebsiteMultiCompanySale, self).shop(page=page, category=category, search=search, ppg=ppg, **post) + categs = request.env['product.public.category'].search([ + ('parent_id', '=', False), + '|', + ('website_ids', '=', False), + ('website_ids', 'in', [request.website.id]), + ]) + response.qcontext.update({ + 'categories': categs, + }) + return response diff --git a/ext/3rd-party-addons/website_multi_company_sale/doc/changelog.rst b/ext/3rd-party-addons/website_multi_company_sale/doc/changelog.rst new file mode 100644 index 00000000..61cd61f5 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/doc/changelog.rst @@ -0,0 +1,24 @@ +`1.2.0` +------- + +- **ADD:** you can now specify allowed websites for your payment acquirers + +`1.1.0` +------- + +- **ADD:** you can now specify allowed websites for your products + +`1.0.2` +------- + +- **ADD:** possibility to specify Salesperson, Sales Channel per each website + +`1.0.1` +------- + +- **FIX:** add multi-company support for carts + +`1.0.0` +------- + +- Init version diff --git a/ext/3rd-party-addons/website_multi_company_sale/doc/index.rst b/ext/3rd-party-addons/website_multi_company_sale/doc/index.rst new file mode 100644 index 00000000..0de660a1 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/doc/index.rst @@ -0,0 +1,72 @@ +========================================== + Real Multi Website (eCommerce extension) +========================================== + +Installation +============ + +* `Install `__ this module in a usual way + +Configuration +============= + +Follow instruction of the base module `Real Multi Website `__. + +Website Orders +-------------- + +* Open menu ``[[ Website ]] >> Configuration >> Websites`` +* For each website configure **Salesperson** and **Sales Channel** fields +* RESULT: new orders made via website will be assigned to proper Salesperson and Sales Channel + +Multi-categories +---------------- + +* Open menu ``[[ Website ]] >> Configuration >> Products >> eCommerce Categories`` +* Only for top-level (i.e. without ``parent_id``) categories: specify **Websites** field + +Multi-products +-------------- +* Open menu ``[[ Sales ]] >> Sales >> Products`` +* Specify **Allowed websites** for your products +* Websites company and product company should be equal. But if you want different company websites then leave the **Company** field empty in your product - in such case you can specify any websites + +Multi-payment-acquirers +----------------------- +* Open menu ``[[ Website ]] >> Configuration >> eCommerce >> Payment Acquirers`` +* Specify **Allowed websites** for your payment acquirer. If no website is specified then the acquirer will be available on any website with the same company +* Choosen websites companies and acquirer's company should be equal + + +Usage +===== + +Multi-categories +---------------- + +* Open shop at some of your websites +* Login as Administrator +* In ``Customize`` section activate ``[x] eCommerce Categories`` +* RESULT: parent categories for current website and categories without value at **Websites** fields are shown only. **Websites** value of child categories are ignored. + +Multi-cart +---------- + +* Login as portal or internal user at some of your websites +* Add some products to the cart +* Open another website that belongs to another company +* Login as the same user +* RESULT: you have empty cart, rather than one from previous website + +Multi-products +-------------- + +* Open website shop +* RESULT: you should only see products allowed for this website or products with no websites specified + +Multi-payment-acquirers +----------------------- + +* Open website shop +* Buy a product +* On Payment step of checkout there should be available only specified acquirers diff --git a/ext/3rd-party-addons/website_multi_company_sale/images/website_multi_company_sale_main.png b/ext/3rd-party-addons/website_multi_company_sale/images/website_multi_company_sale_main.png new file mode 100644 index 00000000..2478e3c9 Binary files /dev/null and b/ext/3rd-party-addons/website_multi_company_sale/images/website_multi_company_sale_main.png differ diff --git a/ext/3rd-party-addons/website_multi_company_sale/models/__init__.py b/ext/3rd-party-addons/website_multi_company_sale/models/__init__.py new file mode 100644 index 00000000..62909dc0 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/models/__init__.py @@ -0,0 +1,4 @@ +from . import product_public_category +from . import sale_order +from . import product_template +from . import payment_acquirer diff --git a/ext/3rd-party-addons/website_multi_company_sale/models/payment_acquirer.py b/ext/3rd-party-addons/website_multi_company_sale/models/payment_acquirer.py new file mode 100644 index 00000000..d121c383 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/models/payment_acquirer.py @@ -0,0 +1,20 @@ +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError + + +class PaymentAcquirer(models.Model): + _inherit = 'payment.acquirer' + + website_ids = fields.Many2many('website', string='Allowed websites', + help='Set the websites this payment acquirer should be available on. Leave empty to allow all.') + + @api.onchange('company_id') + def _onchange_company_id(self): + return self.company_id and {'domain': {'website_ids': [('company_id', '=', self.company_id.id)]}} or {'domain': {'website_ids': []}} + + @api.constrains('company_id', 'website_ids') + def _check_websites_in_company(self): + for record in self: + website_company = record.website_ids.mapped('company_id') + if record.company_id and record.website_ids and (len(website_company) > 1 or website_company[0] != record.company_id): + raise ValidationError(_("Error! Only the company's websites are allowed")) diff --git a/ext/3rd-party-addons/website_multi_company_sale/models/product_public_category.py b/ext/3rd-party-addons/website_multi_company_sale/models/product_public_category.py new file mode 100644 index 00000000..aba874e8 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/models/product_public_category.py @@ -0,0 +1,11 @@ +from odoo import models, fields + + +class ProductPublicCategory(models.Model): + _inherit = "product.public.category" + + website_ids = fields.Many2many( + 'website', + string="Websites", + help="On which websites show category. Keep empty to show at all websites. The value is ignored if there is Parent Category" + ) diff --git a/ext/3rd-party-addons/website_multi_company_sale/models/product_template.py b/ext/3rd-party-addons/website_multi_company_sale/models/product_template.py new file mode 100644 index 00000000..f67a1ebe --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/models/product_template.py @@ -0,0 +1,22 @@ + +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + website_ids = fields.Many2many('website', string='Allowed websites', + help='Set the websites this product should be available on. Leave empty to allow all.') + + @api.onchange('company_id') + def _onchange_company_id(self): + return self.company_id and {'domain': {'website_ids': [('company_id', '=', self.company_id.id)]}} or {'domain': {'website_ids': []}} + + @api.constrains('company_id', 'website_ids') + def _check_websites_in_company(self): + for record in self: + website_company = record.website_ids.mapped('company_id') + if record.company_id and record.website_ids and (len(website_company) > 1 or website_company[0] != record.company_id): + raise ValidationError(_("Error! Only the company's websites are allowed. \ + Leave the Company field empty if you want websites from different companies")) diff --git a/ext/3rd-party-addons/website_multi_company_sale/models/sale_order.py b/ext/3rd-party-addons/website_multi_company_sale/models/sale_order.py new file mode 100644 index 00000000..d9c11383 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/models/sale_order.py @@ -0,0 +1,24 @@ +from odoo import models, api, fields +from odoo.http import request + + +class Website(models.Model): + _inherit = 'website' + + @api.multi + def sale_get_order(self, force_create=False, code=None, update_pricelist=False, force_pricelist=False): + company = request.website.company_id + if not request.session.get('sale_order_id'): + # original sale_get_order uses last_website_so_id only when there is + # sale_order_id in the session + + # company.id seems to be the same as self.id, but let's use variant + # from original sale_get_order + self = self.with_context(force_company=company.id) + return super(Website, self).sale_get_order(force_create, code, update_pricelist, force_pricelist) + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + last_website_so_id = fields.Many2one(company_dependent=True) diff --git a/ext/3rd-party-addons/website_multi_company_sale/security/website_multi_company_sale_security.xml b/ext/3rd-party-addons/website_multi_company_sale/security/website_multi_company_sale_security.xml new file mode 100644 index 00000000..201f0330 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/security/website_multi_company_sale_security.xml @@ -0,0 +1,13 @@ + + + + Products available only for specifed websites (shops) + + ['|', ('website_ids', 'in', [website_id]), ('website_ids', '=', False)] + + + Payment acquirers available only for specifed websites (shops) + + ['|', ('website_ids', 'in', [website_id]), ('website_ids', '=', False)] + + diff --git a/ext/3rd-party-addons/website_multi_company_sale/static/description/icon.png b/ext/3rd-party-addons/website_multi_company_sale/static/description/icon.png new file mode 100644 index 00000000..213cccf5 Binary files /dev/null and b/ext/3rd-party-addons/website_multi_company_sale/static/description/icon.png differ diff --git a/ext/3rd-party-addons/website_multi_company_sale/static/description/index.html b/ext/3rd-party-addons/website_multi_company_sale/static/description/index.html new file mode 100644 index 00000000..dbd32caa --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/static/description/index.html @@ -0,0 +1,92 @@ +
+
+
+

Real Multi Website (eCommerce extension)

+
+
+
+ +
+
+
+ +
+ Key features: +
    + +
  • + + All features of Real Multi Website module +
  • + +
  • + + Each eCommerce has configurable list of product categories +
  • +
  • + + eCommerce carts are separate per each company to avoid accounting problems +
  • +
  • + + The same product can be available on several websites (shops) +
  • + +
+
+ +
+
+
+ +
+
+
+

Need our service?

+

Contact us by email or fill out request form

+ +
+
+
+
+ Tested on Odoo
11.0 community +
+
+ Tested on Odoo
11.0 enterprise +
+
+
+
+
+ diff --git a/ext/3rd-party-addons/website_multi_company_sale/views/payment_views.xml b/ext/3rd-party-addons/website_multi_company_sale/views/payment_views.xml new file mode 100644 index 00000000..7e521ec5 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/views/payment_views.xml @@ -0,0 +1,14 @@ + + + + payment.acquirer.form.inherit.website_multi_company_sale + payment.acquirer + + + + + + + + + diff --git a/ext/3rd-party-addons/website_multi_company_sale/views/product_public_category_views.xml b/ext/3rd-party-addons/website_multi_company_sale/views/product_public_category_views.xml new file mode 100644 index 00000000..8e6a1397 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/views/product_public_category_views.xml @@ -0,0 +1,26 @@ + + + + + product.public.category.form + product.public.category + + + + + + + + + + product.public.category.tree + product.public.category + + + + + + + + + diff --git a/ext/3rd-party-addons/website_multi_company_sale/views/product_template_views.xml b/ext/3rd-party-addons/website_multi_company_sale/views/product_template_views.xml new file mode 100644 index 00000000..71819d87 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/views/product_template_views.xml @@ -0,0 +1,13 @@ + + + + product.template.form.inherit.website_multi_company_sale + product.template + + + + + + + + diff --git a/ext/3rd-party-addons/website_multi_company_sale/views/website_views.xml b/ext/3rd-party-addons/website_multi_company_sale/views/website_views.xml new file mode 100644 index 00000000..3f7ce963 --- /dev/null +++ b/ext/3rd-party-addons/website_multi_company_sale/views/website_views.xml @@ -0,0 +1,17 @@ + + + + + website + + + + + + + + + + + +