minor fix products
This commit is contained in:
parent
1fd3a71d33
commit
9ddeae7219
|
@ -7,6 +7,7 @@
|
|||
node_modules/
|
||||
dist/
|
||||
build/
|
||||
*.egg-info/
|
||||
|
||||
# Compiled Java class files
|
||||
*.class
|
||||
|
|
|
@ -29,6 +29,8 @@ class MercadoLibre(SaleWebChannel):
|
|||
super(MercadoLibre, cls).__setup__()
|
||||
cls._error_messages.update({
|
||||
'product_not_found': ('Product Not Found'),
|
||||
'product_generic_not_found': ('Product Generic Not Found, Verify in Configuration'),
|
||||
# 'product_generic': ('The sale will be created with generic product "%s"')
|
||||
})
|
||||
|
||||
def _get_context(self):
|
||||
|
@ -176,6 +178,8 @@ class MercadoLibre(SaleWebChannel):
|
|||
sales = Sale.search([
|
||||
('reference', '=', str(sale_['id']))
|
||||
])
|
||||
# print(sales[0].number)
|
||||
|
||||
if sales:
|
||||
if len(sales) == 1 and sale_['status'] == 'cancelled':
|
||||
sale = sales[0]
|
||||
|
@ -233,20 +237,28 @@ class MercadoLibre(SaleWebChannel):
|
|||
for line in sale_items:
|
||||
item = line['item']
|
||||
sku_code = item['seller_sku']
|
||||
if sku_code.count('+') > 0:
|
||||
codes = sku_code.split('+')
|
||||
line['unit_price'] = Decimal(round((line['unit_price'] / 2), 2))
|
||||
if sku_code:
|
||||
if sku_code.count('+') > 0:
|
||||
codes = sku_code.split('+')
|
||||
line['unit_price'] = Decimal(round((line['unit_price'] / 2), 2))
|
||||
else:
|
||||
codes = [sku_code]
|
||||
products = Product.search([
|
||||
('code', 'in', codes),
|
||||
('active', '=', True)
|
||||
])
|
||||
description = ''
|
||||
if not products:
|
||||
products = self._create_product(codes, line)
|
||||
else:
|
||||
codes = [sku_code]
|
||||
products = Product.search([
|
||||
('code', 'in', codes),
|
||||
('active', '=', True)
|
||||
])
|
||||
description = ''
|
||||
if not products:
|
||||
products = self._create_product(codes, line)
|
||||
# self.raise_user_error('product_not_found')
|
||||
# return False
|
||||
if not self.generic_product:
|
||||
return self.raise_user_error('product_generic_not_found')
|
||||
products = [self.generic_product]
|
||||
generic = True
|
||||
description = ''
|
||||
self.raise_user_warning('product_generic',
|
||||
'The sale will be created with generic product \n %s'
|
||||
% self.generic_product.rec_name)
|
||||
for product in products:
|
||||
Tax = _pool.get('account.tax')
|
||||
un_price = Tax.reverse_compute(line['unit_price'],
|
||||
|
@ -283,7 +295,8 @@ class MercadoLibre(SaleWebChannel):
|
|||
sale.state = 'cancel'
|
||||
else:
|
||||
Sale.quote([sale])
|
||||
sale.state = 'confirmed'
|
||||
if generic:
|
||||
sale.state = 'confirmed'
|
||||
sale.save()
|
||||
# if shipment_['status'] in ['shipped', 'delivered']:
|
||||
# self._finish_sale(sale)
|
||||
|
|
|
@ -46,6 +46,8 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
|||
<field name="bonus_product"/>
|
||||
<label name="invoice_type"/>
|
||||
<field name="invoice_type"/>
|
||||
<label name="generic_product"/>
|
||||
<field name="generic_product"/>
|
||||
<label name="tip_product"/>
|
||||
<field name="tip_product"/>
|
||||
<label name="template_notification"/>
|
||||
|
|
|
@ -101,6 +101,11 @@ class SaleWebChannel(Workflow, ModelSQL, ModelView):
|
|||
'invisible': (Eval('channel_name') != 'shopify'),
|
||||
'readonly': (Eval('state') != 'draft')
|
||||
})
|
||||
|
||||
generic_product = fields.Many2One('product.product', 'Generic Product', states={
|
||||
# 'invisible': (Eval('channel_name') != 'shopify'),
|
||||
'readonly': (Eval('state') != 'draft')
|
||||
})
|
||||
report = fields.Many2One('ir.action.report', 'Report', states=STATES)
|
||||
invoice_type = fields.Selection(TYPE_INVOICE, 'Type Invoice',
|
||||
states=STATES)
|
||||
|
@ -274,6 +279,7 @@ class SynchronizeChannelOrders(Wizard):
|
|||
if channel.channel_name == 'mercadolibre':
|
||||
MercadoLibre = pool.get('sale.web_channel.mercado_libre')
|
||||
channel = MercadoLibre(channel)
|
||||
|
||||
if operation == 'especific_order':
|
||||
order_id = self.start.order_id
|
||||
URI = 'https://api.mercadolibre.com/orders/%s?access_token=%s' % (
|
||||
|
@ -282,10 +288,12 @@ class SynchronizeChannelOrders(Wizard):
|
|||
if not result:
|
||||
self.raise_user_error('error', result)
|
||||
sale_created = channel._create_sale(result)
|
||||
|
||||
generic_code = self.start.channel.generic_product.code if self.start.channel.generic_product else None
|
||||
product_generic = [line.product.code for line in sale_created.lines if line.product.code == generic_code and generic_code]
|
||||
if sale_created and \
|
||||
not sale_created.pack_id and \
|
||||
sale_created.comment in ['shipped', 'delivered']:
|
||||
sale_created.comment in ['shipped', 'delivered'] and \
|
||||
len(product_generic) < 1:
|
||||
Sale.process([sale_created])
|
||||
else:
|
||||
date_from = str(self.start.date) + 'T00:00:00.000-00:00'
|
||||
|
|
Loading…
Reference in New Issue