Modul website_multi_company_sale hinzugefügt
							parent
							
								
									fca68900d2
								
							
						
					
					
						commit
						3540239a62
					
				|  | @ -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 <https://it-projects.info/team/yelizariev>`__ | ||||
| 
 | ||||
| Sponsors | ||||
| -------- | ||||
| * `IT-Projects LLC <https://it-projects.info>`__ | ||||
| 
 | ||||
| Maintainers | ||||
| ----------- | ||||
| * `IT-Projects LLC <https://it-projects.info>`__ | ||||
| 
 | ||||
|       To get a guaranteed support you are kindly requested to purchase the module at `odoo apps store <https://apps.odoo.com/apps/modules/11.0/website_multi_company_sale/>`__. | ||||
| 
 | ||||
|       Thank you for understanding! | ||||
| 
 | ||||
|       `IT-Projects Team <https://www.it-projects.info/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: `<doc/index.rst>`_ | ||||
| 
 | ||||
| Changelog: `<doc/changelog.rst>`_ | ||||
| 
 | ||||
| Tested on Odoo 11.0 f34d4d33a09d33a12e427c2490b6526546114486 | ||||
|  | @ -0,0 +1,2 @@ | |||
| from . import models | ||||
| from . import controllers | ||||
|  | @ -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, | ||||
| } | ||||
|  | @ -0,0 +1 @@ | |||
| from . import main | ||||
|  | @ -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 | ||||
|  | @ -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 | ||||
|  | @ -0,0 +1,72 @@ | |||
| ========================================== | ||||
|  Real Multi Website (eCommerce extension) | ||||
| ========================================== | ||||
| 
 | ||||
| Installation | ||||
| ============ | ||||
| 
 | ||||
| * `Install <https://odoo-development.readthedocs.io/en/latest/odoo/usage/install-module.html>`__ this module in a usual way | ||||
| 
 | ||||
| Configuration | ||||
| ============= | ||||
| 
 | ||||
| Follow instruction of the base module `Real Multi Website <https://www.odoo.com/apps/modules/11.0/website_multi_company/>`__. | ||||
| 
 | ||||
| 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 | ||||
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 298 KiB | 
|  | @ -0,0 +1,4 @@ | |||
| from . import product_public_category | ||||
| from . import sale_order | ||||
| from . import product_template | ||||
| from . import payment_acquirer | ||||
|  | @ -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")) | ||||
|  | @ -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" | ||||
|     ) | ||||
|  | @ -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")) | ||||
|  | @ -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) | ||||
|  | @ -0,0 +1,13 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <odoo> | ||||
|   <record id="website_multi_company_sale_rule_all" model="ir.rule"> | ||||
|     <field name="name">Products available only for specifed websites (shops)</field> | ||||
|     <field name="model_id" ref="model_product_template"/> | ||||
|     <field name="domain_force">['|', ('website_ids', 'in', [website_id]), ('website_ids', '=', False)]</field> | ||||
|   </record> | ||||
|   <record id="website_multi_company_payment_rule_all" model="ir.rule"> | ||||
|     <field name="name">Payment acquirers available only for specifed websites (shops)</field> | ||||
|     <field name="model_id" ref="model_payment_acquirer"/> | ||||
|     <field name="domain_force">['|', ('website_ids', 'in', [website_id]), ('website_ids', '=', False)]</field> | ||||
|   </record> | ||||
| </odoo> | ||||
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 2.2 KiB | 
|  | @ -0,0 +1,92 @@ | |||
| <section class="oe_container"> | ||||
|     <div class="oe_row oe_spaced"> | ||||
|         <div class="oe_span12"> | ||||
|             <h2 class="oe_slogan" style="color:#875A7B;">Real Multi Website (eCommerce extension)</h2> | ||||
|         </div> | ||||
|     </div> | ||||
| </section> | ||||
| 
 | ||||
| <section class="oe_container"> | ||||
|   <div class="oe_row oe_spaced"> | ||||
|     <div class="oe_span12"> | ||||
| 
 | ||||
|     <div class="alert alert-info oe_mt32" style="padding:0.3em 0.6em; font-size: 150%;"> | ||||
|       <i class="fa fa-hand-o-right"></i><b> Key features: </b> | ||||
|       <ul class="list-unstyled"> | ||||
| 
 | ||||
|         <li> | ||||
|         <i class="fa fa-check-square-o text-primary"></i> | ||||
|           All features of <a href="https://apps.odoo.com/apps/modules/11.0/website_multi_company">Real Multi Website</a> module | ||||
|         </li> | ||||
| 
 | ||||
|         <li> | ||||
|         <i class="fa fa-check-square-o text-primary"></i> | ||||
|            Each eCommerce has configurable list of product categories | ||||
|         </li> | ||||
|         <li> | ||||
|         <i class="fa fa-check-square-o text-primary"></i> | ||||
|            eCommerce carts are separate per each company to avoid accounting problems | ||||
|         </li> | ||||
|         <li> | ||||
|         <i class="fa fa-check-square-o text-primary"></i> | ||||
|            The same product can be available on several websites (shops) | ||||
|         </li> | ||||
| 
 | ||||
|       </ul> | ||||
|     </div> | ||||
| 
 | ||||
|     </div> | ||||
|   </div> | ||||
| </section> | ||||
| 
 | ||||
| <section class="oe_container"> | ||||
|     <div class="oe_row oe_spaced"> | ||||
|         <div class="oe_span8"> | ||||
|             <h2>Need our service?</h2> | ||||
|             <p class="oe_mt32">Contact us by <a href="mailto:apps@it-projects.info">email</a> or fill out <a href="https://www.it-projects.info/page/website.contactus " target="_blank">request form</a></p> | ||||
|             <ul> | ||||
|                 <li><a href="mailto:apps@it-projects.info">apps@it-projects.info <i class="fa fa-envelope-o"></i></a></li> | ||||
|                 <li><a href="https://www.it-projects.info/page/website.contactus " target="_blank">https://www.it-projects.info/page/website.contactus <i class="fa fa-list-alt"></i></a></li> | ||||
|             </ul> | ||||
|         </div> | ||||
|         <div class="oe_span4"> | ||||
|             <div class="stamp" style="width:200px;"> | ||||
|                 <div style="margin-top: 15px; | ||||
|                             position: relative; | ||||
|                             font-family:'Vollkorn', serif; | ||||
|                             font-size: 16px; | ||||
|                             line-height: 25px; | ||||
|                             text-transform: uppercase; | ||||
|                             font-weight: bold; | ||||
|                             color: #75526b; | ||||
|                             border: 3px dashed #75526b; | ||||
|                             float: left; | ||||
|                             padding: 4px 12px; | ||||
|                             -webkit-transform: rotate(7deg); | ||||
|                             -o-transform: rotate(7deg); | ||||
|                             -moz-transform: rotate(7deg); | ||||
|                             -ms-transform: rotate(7deg);"> | ||||
|                     Tested on Odoo<br/>11.0 community | ||||
|                 </div> | ||||
|                 <div style="margin-top: 15px; | ||||
|                             position: relative; | ||||
|                             font-family:'Vollkorn', serif; | ||||
|                             font-size: 16px; | ||||
|                             line-height: 25px; | ||||
|                             text-transform: uppercase; | ||||
|                             font-weight: bold; | ||||
|                             color: #75526b; | ||||
|                             border: 3px dashed #75526b; | ||||
|                             float: left; | ||||
|                             padding: 4px 12px; | ||||
|                             -webkit-transform: rotate(-3deg); | ||||
|                             -o-transform: rotate(-3deg); | ||||
|                             -moz-transform: rotate(-3deg); | ||||
|                             -ms-transform: rotate(-3deg);"> | ||||
|                     Tested on Odoo<br/>11.0 enterprise | ||||
|                 </div> | ||||
|             </div> | ||||
|         </div> | ||||
|     </div> | ||||
| </section> | ||||
| 
 | ||||
|  | @ -0,0 +1,14 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <odoo> | ||||
|   <record id="acquirer_form_view_inherit_website_multi_company_sale" model="ir.ui.view"> | ||||
|     <field name="name">payment.acquirer.form.inherit.website_multi_company_sale</field> | ||||
|     <field name="model">payment.acquirer</field> | ||||
|     <field name="inherit_id" ref="payment.acquirer_form"/> | ||||
|     <field name="arch" type="xml"> | ||||
|       <xpath expr="//field[@name='company_id']" position="after"> | ||||
|         <field name="website_ids" widget="many2many_tags" domain="company_id and [('company_id', '=', company_id)] or []"/> | ||||
|       </xpath> | ||||
|     </field> | ||||
|   </record> | ||||
| </odoo> | ||||
| 
 | ||||
|  | @ -0,0 +1,26 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <odoo> | ||||
| 
 | ||||
|     <record id="product_public_category_form_view" model="ir.ui.view"> | ||||
|         <field name="name">product.public.category.form</field> | ||||
|         <field name="model">product.public.category</field> | ||||
|         <field name="inherit_id" ref="website_sale.product_public_category_form_view"/> | ||||
|         <field name="arch" type="xml"> | ||||
|             <xpath expr="//field[@name='sequence']" position="after"> | ||||
|                 <field name="website_ids" widget="many2many_tags" attrs="{'readonly': [('parent_id', '!=', False)]}"/> | ||||
|             </xpath> | ||||
|         </field> | ||||
|     </record> | ||||
| 
 | ||||
|     <record id="product_public_category_tree_view" model="ir.ui.view"> | ||||
|         <field name="name">product.public.category.tree</field> | ||||
|         <field name="model">product.public.category</field> | ||||
|         <field name="inherit_id" ref="website_sale.product_public_category_tree_view"/> | ||||
|         <field name="arch" type="xml"> | ||||
|             <xpath expr="//field[@name='display_name']" position="after"> | ||||
|                 <field name="website_ids" widget="many2many_tags"/> | ||||
|             </xpath> | ||||
|         </field> | ||||
|     </record> | ||||
| 
 | ||||
| </odoo> | ||||
|  | @ -0,0 +1,13 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <odoo> | ||||
|   <record id="product_template_form_view_inherit_website_multi_comapny_sale" model="ir.ui.view"> | ||||
|     <field name="name">product.template.form.inherit.website_multi_company_sale</field> | ||||
|     <field name="model">product.template</field> | ||||
|     <field name="inherit_id" ref="product.product_template_form_view"/> | ||||
|     <field name="arch" type="xml"> | ||||
|       <xpath expr="//field[@name='company_id']" position="after"> | ||||
|           <field name="website_ids" widget="many2many_tags" domain="company_id and [('company_id', '=', company_id)] or []"/> | ||||
|       </xpath> | ||||
|     </field> | ||||
|   </record> | ||||
| </odoo> | ||||
|  | @ -0,0 +1,17 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <odoo> | ||||
| 
 | ||||
|     <record id="view_website_multi_company_form" model="ir.ui.view"> | ||||
|         <field name="model">website</field> | ||||
|         <field name="inherit_id" ref="website_multi_company.view_website_multi_company_form"/> | ||||
|         <field name="arch" type="xml"> | ||||
|             <xpath expr="//div[@name='shop']" position="inside"> | ||||
|                 <group string="Assignation of online orders"> | ||||
|                     <field name="salesperson_id"/> | ||||
|                     <field name="salesteam_id"/> | ||||
|                 </group> | ||||
|             </xpath> | ||||
|         </field> | ||||
|     </record> | ||||
| 
 | ||||
| </odoo> | ||||
		Loading…
	
		Reference in New Issue