Feedback 1671: Preislisten in SST-02
							parent
							
								
									eb889a37bd
								
							
						
					
					
						commit
						c27c6d5611
					
				|  | @ -18,11 +18,11 @@ | |||
| #    along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
| # | ||||
| ############################################################################## | ||||
| from odoo.addons.component.core import Component | ||||
| 
 | ||||
| from odoo import fields, models, api, _ | ||||
| from odoo.exceptions import ValidationError | ||||
| 
 | ||||
| from odoo.addons.component.core import Component | ||||
| 
 | ||||
| 
 | ||||
| class ProductXCategory(models.Model): | ||||
|     _name = 'product.xcategory' | ||||
|  | @ -142,21 +142,30 @@ class ProductPricelistItemEventListener(Component): | |||
| 
 | ||||
|     @api.model | ||||
|     def on_record_write(self, record, fields=None): | ||||
|         partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.id)]) | ||||
|         partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.pricelist_id.id)]) | ||||
|         for partner in partners: | ||||
|             if partner.portal_id and partner.active: | ||||
|             if partner.portal_id and partner.company_type == 'company': | ||||
|                 partner.portal_export_pending = True | ||||
| 
 | ||||
|     @api.model | ||||
|     def on_record_create(self, record, fields=None): | ||||
|         partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.id)]) | ||||
|         partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.pricelist_id.id)]) | ||||
|         for partner in partners: | ||||
|             if partner.portal_id: | ||||
|             if partner.portal_id and partner.company_type == 'company': | ||||
|                 partner.portal_export_pending = True | ||||
| 
 | ||||
|     @api.model | ||||
|     def on_record_unlink(self, record): | ||||
|         partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.id)]) | ||||
|         partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.pricelist_id.id)]) | ||||
|         for partner in partners: | ||||
|             if partner.portal_id: | ||||
|             if partner.portal_id and partner.company_type == 'company': | ||||
|                 partner.portal_export_pending = True | ||||
| 
 | ||||
| 
 | ||||
| class ProductPricelistItem(models.Model): | ||||
|     _inherit = 'product.pricelist.item' | ||||
| 
 | ||||
|     applied_on = fields.Selection(selection=[ | ||||
|         ('3_global', 'Global'), | ||||
|         ('2_product_category', ' Product Category'), | ||||
|         ('0_product_variant', 'Product Variant')]) | ||||
|  |  | |||
|  | @ -34,16 +34,12 @@ class PartnerEventListener(Component): | |||
|     _apply_on = ['res.partner'] | ||||
| 
 | ||||
|     def on_record_write(self, record, fields=None): | ||||
|         if record.active and record.portal_id: | ||||
|             if 'company_type' in fields: | ||||
|                 if record.company_type == 'company' and record.type != 'delivery': | ||||
|         if record.active and record.portal_id and record.company_type == 'company': | ||||
|             if 'company_type' in fields or 'property_product_pricelist' in fields: | ||||
|                 self.env['res.partner'].with_delay().job_export_portal_price(record) | ||||
|             if 'property_product_pricelist' in fields: | ||||
|                 for contact in record.child_ids: | ||||
|                     if contact.type != 'delivery': | ||||
|                         self.env['res.partner'].with_delay().job_export_portal_price(contact) | ||||
|             if 'parent_id' in fields: | ||||
|                 if record.type != 'delivery': | ||||
| 
 | ||||
|     def on_record_create(self, record, fields=None): | ||||
|         if record.active and record.portal_id and record.company_type == 'company': | ||||
|             self.env['res.partner'].with_delay().job_export_portal_price(record) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -283,7 +279,6 @@ class Partner(models.Model): | |||
|     def cron_export_portal_prices(self): | ||||
|         partners = self.search([('portal_export_pending', '=', True), ('company_id', '=', self.env.user.company_id.id)]) | ||||
|         for partner in partners: | ||||
|             if partner.type != 'delivery': | ||||
|             self.with_delay().job_export_portal_price(partner) | ||||
|             partner.portal_export_pending = False | ||||
| 
 | ||||
|  | @ -296,14 +291,14 @@ class Partner(models.Model): | |||
|         data = [] | ||||
|         for item in pricelist.item_ids: | ||||
|             if item.compute_price == 'percentage' and item.applied_on in ['3_global', '2_product_category', | ||||
|                                                                           '1_product']: | ||||
|                                                                           '0_product_variant']: | ||||
|                 code = False | ||||
|                 if item.applied_on == '2_product_category': | ||||
|                     code = item.categ_id.code | ||||
|                 if item.applied_on == '1_product': | ||||
|                 if item.applied_on == '0_product_variant': | ||||
|                     code = item.product_tmpl_id.default_code | ||||
|                 data.append({ | ||||
|                     'customer_id': partner_id.portal_id, | ||||
|                     'customer_id': partner_id.commercial_partner_id.portal_id, | ||||
|                     'code': code, | ||||
|                     'discount': 1 - (item.percent_price / 100) | ||||
|                 }) | ||||
|  |  | |||
|  | @ -62,6 +62,17 @@ | |||
|         </field> | ||||
|     </record> | ||||
| 
 | ||||
|     <record id="dp_product_pricelist_item_form_view" model="ir.ui.view"> | ||||
|         <field name="name">dp_product_pricelist_item_form_view</field> | ||||
|         <field name="model">product.pricelist.item</field> | ||||
|         <field name="inherit_id" ref="product.product_pricelist_item_form_view"/> | ||||
|         <field name="arch" type="xml"> | ||||
|             <field name="applied_on" position="attributes"> | ||||
|                 <attribute name="attrs">{'invisible':[('applied_on', '=', '1_product')]}</attribute> | ||||
|             </field> | ||||
|         </field> | ||||
|     </record> | ||||
| 
 | ||||
|     <record id="product_xcategory_form_view" model="ir.ui.view"> | ||||
|         <field name="name">product_xcategory_form_view</field> | ||||
|         <field name="model">product.xcategory</field> | ||||
|  |  | |||
|  | @ -64,7 +64,7 @@ class PortalAssignCompany(models.TransientModel): | |||
| 
 | ||||
|         # Wichtig hier ist, dass dieser Call vor dem ersten Write stattfindet, da das Portal | ||||
|         # parallel einen Call absetzt, dann dann blockieren würde. | ||||
|         self.send_to_portal(partner.portal_id, partner.id) | ||||
|         # self.send_to_portal(partner.portal_id, partner.id) | ||||
|         partner.write({'portal_pending': False, 'active': True}) | ||||
| 
 | ||||
|         return True | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue