Fall 234: Versandarten - Webshop
							parent
							
								
									96685848ec
								
							
						
					
					
						commit
						2c89af2532
					
				|  | @ -12,11 +12,12 @@ | ||||||
|     'support': 'office@datenpol.at', |     'support': 'office@datenpol.at', | ||||||
|     'website': 'https://www.datenpol.at', |     'website': 'https://www.datenpol.at', | ||||||
|     'depends': [ |     'depends': [ | ||||||
|         'website', |         'delivery', | ||||||
|         'website_multi_theme', |         'website_sale_delivery', | ||||||
|         'website_multi_company_sale', |         'website_multi_company_sale', | ||||||
|     ], |     ], | ||||||
|     'data': [ |     'data': [ | ||||||
|  |         'views/delivery_carrier.xml', | ||||||
|         'security/rule.xml' |         'security/rule.xml' | ||||||
|     ], |     ], | ||||||
|     'installable': True, |     'installable': True, | ||||||
|  |  | ||||||
|  | @ -1,2 +1,3 @@ | ||||||
| from . import sale_order | from . import sale_order | ||||||
| from . import stock_picking | from . import stock_picking | ||||||
|  | from . import delivery_carrier | ||||||
|  |  | ||||||
|  | @ -0,0 +1,26 @@ | ||||||
|  | # Copyright 2018-Today datenpol gmbh (<http://www.datenpol.at>) | ||||||
|  | # License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). | ||||||
|  | 
 | ||||||
|  | from odoo import api, fields, models, _ | ||||||
|  | from odoo.exceptions import ValidationError | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | class DeliveryCarrier(models.Model): | ||||||
|  |     _inherit = 'delivery.carrier' | ||||||
|  | 
 | ||||||
|  |     website_ids = fields.Many2many('website', string='Allowed websites', | ||||||
|  |                                    help='Set the websites this delivery carrier 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")) | ||||||
|  | @ -16,3 +16,11 @@ class SaleOrder(models.Model): | ||||||
|         sale_template.send_mail(self.id) |         sale_template.send_mail(self.id) | ||||||
| 
 | 
 | ||||||
|         return result |         return result | ||||||
|  | 
 | ||||||
|  |     def _get_delivery_methods(self): | ||||||
|  |         address = self.partner_shipping_id | ||||||
|  |         return self.env['delivery.carrier'].sudo().search([ | ||||||
|  |             ('website_published', '=', True), '|', | ||||||
|  |             ('website_ids', '=', False), | ||||||
|  |             ('website_ids', 'in', [self.env.context.get('website_id', False)]), | ||||||
|  |         ]).available_carriers(address) | ||||||
|  |  | ||||||
|  | @ -1,3 +1,7 @@ | ||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <!-- Copyright 2018-Today datenpol gmbh(<http://www.datenpol.at>) | ||||||
|  |      License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). --> | ||||||
|  | 
 | ||||||
| <odoo> | <odoo> | ||||||
|     <record id="website_multi_company_sale.website_multi_company_sale_rule_all" model="ir.rule"> |     <record id="website_multi_company_sale.website_multi_company_sale_rule_all" model="ir.rule"> | ||||||
|         <field name="backend_behaviour">true</field> |         <field name="backend_behaviour">true</field> | ||||||
|  | @ -5,4 +9,11 @@ | ||||||
|     <record id="website_multi_company_sale.website_multi_company_payment_rule_all" model="ir.rule"> |     <record id="website_multi_company_sale.website_multi_company_payment_rule_all" model="ir.rule"> | ||||||
|         <field name="backend_behaviour">true</field> |         <field name="backend_behaviour">true</field> | ||||||
|     </record> |     </record> | ||||||
|  | 
 | ||||||
|  |     <record id="website_multi_company_delivery_rule_all" model="ir.rule"> | ||||||
|  |         <field name="name">Delivery Carrier available only for specifed websites (shops)</field> | ||||||
|  |         <field name="model_id" ref="delivery.model_delivery_carrier"/> | ||||||
|  |         <field name="domain_force">['|', ('website_ids', 'in', [website_id]), ('website_ids', '=', False)]</field> | ||||||
|  |         <field name="backend_behaviour">true</field> | ||||||
|  |     </record> | ||||||
| </odoo> | </odoo> | ||||||
|  |  | ||||||
|  | @ -0,0 +1,17 @@ | ||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <!-- Copyright 2018-Today datenpol gmbh(<http://www.datenpol.at>) | ||||||
|  |      License OPL-1 or later (https://www.odoo.com/documentation/user/11.0/legal/licenses/licenses.html#licenses). --> | ||||||
|  | 
 | ||||||
|  | <odoo> | ||||||
|  |     <record id="delivery_carrier_from_view" model="ir.ui.view"> | ||||||
|  |         <field name="name">delivery_carrier_from_view</field> | ||||||
|  |         <field name="model">delivery.carrier</field> | ||||||
|  |         <field name="inherit_id" ref="delivery.view_delivery_carrier_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> | ||||||
|  | @ -332,7 +332,7 @@ class DatenpolFunctions(object): | ||||||
|                 'module': 'dp_website', |                 'module': 'dp_website', | ||||||
|                 'name': 'tz_heizpaneele', |                 'name': 'tz_heizpaneele', | ||||||
|                 'res_id': str(heizpaneele), |                 'res_id': str(heizpaneele), | ||||||
|                 'noupdate': False, |                 'noupdate': True, | ||||||
|             } |             } | ||||||
|             ir_model_obj.create(vals) |             ir_model_obj.create(vals) | ||||||
|         else: |         else: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue