FB1776: SST-02 Fehler anzeigen, Partner korrekt markieren
parent
5ef73ab0fc
commit
92aa4c7d8a
|
|
@ -22,7 +22,7 @@ from odoo.addons.component.core import Component
|
|||
|
||||
from odoo import fields, models, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
from odoo.addons.queue_job.job import job
|
||||
|
||||
class ProductXCategory(models.Model):
|
||||
_name = 'product.xcategory'
|
||||
|
|
@ -152,24 +152,15 @@ class ProductPricelistItemEventListener(Component):
|
|||
|
||||
@api.model
|
||||
def on_record_write(self, record, fields=None):
|
||||
partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.pricelist_id.id)])
|
||||
for partner in partners:
|
||||
if partner.portal_id and partner.company_type == 'company':
|
||||
partner.portal_export_pending = True
|
||||
self.env['product.pricelist.item'].with_delay().job_mark_partner_for_export(record.pricelist_id.id)
|
||||
|
||||
@api.model
|
||||
def on_record_create(self, record, fields=None):
|
||||
partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.pricelist_id.id)])
|
||||
for partner in partners:
|
||||
if partner.portal_id and partner.company_type == 'company':
|
||||
partner.portal_export_pending = True
|
||||
self.env['product.pricelist.item'].with_delay().job_mark_partner_for_export(record.pricelist_id.id)
|
||||
|
||||
@api.model
|
||||
def on_record_unlink(self, record):
|
||||
partners = self.env['res.partner'].search([('property_product_pricelist', '=', record.pricelist_id.id)])
|
||||
for partner in partners:
|
||||
if partner.portal_id and partner.company_type == 'company':
|
||||
partner.portal_export_pending = True
|
||||
self.env['product.pricelist.item'].with_delay().job_mark_partner_for_export(record.pricelist_id.id)
|
||||
|
||||
|
||||
class ProductPricelistItem(models.Model):
|
||||
|
|
@ -179,3 +170,12 @@ class ProductPricelistItem(models.Model):
|
|||
('3_global', 'Global'),
|
||||
('2_product_category', ' Product Category'),
|
||||
('0_product_variant', 'Product Variant')])
|
||||
|
||||
@api.multi
|
||||
@job
|
||||
def job_mark_partner_for_export(self, pricelist_id):
|
||||
partners = self.env['res.partner'].search([('company_type','=','company'),('portal_id','!=',False)])
|
||||
for partner in partners:
|
||||
# Search ist auf die Preisliste nicht möglich, daher wird jeder Partner einzeln verglichen
|
||||
if partner.property_product_pricelist.id == pricelist_id:
|
||||
partner.portal_export_pending = True
|
||||
|
|
@ -319,13 +319,16 @@ class Partner(models.Model):
|
|||
'code': code,
|
||||
'discount': 1 - (item.percent_price / 100)
|
||||
})
|
||||
portal_url = tools.config.get('portal_url')
|
||||
application_id = tools.config.get('portal_secret')
|
||||
response = requests.post(portal_url + '/api/v1/set-discounts/?secret=' + application_id,
|
||||
data=json.dumps(data))
|
||||
if response.status_code != 200:
|
||||
raise ValidationError(_('Rabatt konnte nicht gesetzt werden. '
|
||||
'Status Code: %s, Reason: %s') % (response.status_code, response.reason))
|
||||
if data:
|
||||
portal_url = tools.config.get('portal_url')
|
||||
application_id = tools.config.get('portal_secret')
|
||||
response = requests.post(portal_url + '/api/v1/set-discounts/?secret=' + application_id,
|
||||
data=json.dumps(data))
|
||||
if response.status_code != 200:
|
||||
data = response.json()
|
||||
error_string = data.get('errors',[])
|
||||
raise ValidationError(_('Rabatt konnte nicht gesetzt werden. '
|
||||
'Status Code: %s, Reason: %s') % (response.status_code, error_string))
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
|
|
|
|||
Loading…
Reference in New Issue