8000 Changes done in the all the appropriate model files according to the … by techspawn1 · Pull Request #31 · OCA/connector-woocommerce · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Changes done in the all the appropriate model files according to the … #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 8.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

Odoo Connector WooCommerce Modules
===================================
*Odoo WooCommerce Connector (also known as connector_woocommerce) is a bi-directional connector, 100% compatible with the last OpenERP 8.0 and latest WooCommerce versions (2.4.x).*
*Odoo WooCommerce Connector (also known as connector_woocommerce) is a single-directional connector, 100% compatible with the last OpenERP 8.0 and latest WooCommerce versions (2.6.4).*

[//]: # (addons)
Available addons
----------------
addon | version | summary
--- | --- | ---
[connector_woocommerce](connector_woocommerce/) | 8.0.1.0.1 | WooCommerce Connector
[connector_woocommerce](connector_woocommerce/) | 8.0.1.0.2 | WooCommerce Connector

[//]: # (end addons)
13 changes: 11 additions & 2 deletions connector_woocommerce/model/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# Tech-Receptives Solutions Pvt. Ltd.
# Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
# Techspwan Solutions Pvt Ltd.
# Copyright (C) 2016-TODAY Techspawn Solutions(<http://www.techspawn.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
Expand Down Expand Up @@ -79,7 +82,7 @@ def search(self, filters=None, from_date=None, to_date=None):
"""
if filters is None:
filters = {}
WOO_DATETIME_FORMAT = '%Y/%m/%d %H:%M:%S'
WOO_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
dt_fmt = WOO_DATETIME_FORMAT
if from_date is not None:
# updated_at include the created records
Expand All @@ -89,8 +92,14 @@ def search(self, filters=None, from_date=None, to_date=None):
filters.setdefault('updated_at', {})
filters['updated_at']['to'] = to_date.strftime(dt_fmt)
# the search method is on ol_customer instead of customer
return self._call('customers/list',
customer_count = self._call('customers/count',
[filters] if filters else [{}])
get_list = self._call('customers?fields=id&filter[limit]='+str(customer_count['count'])+'&filter[updated_at_max]='+filters['updated_at']['to'] or None +'&filter[updated_at_min]='+filters['updated_at']['from'] or None,
[filters] if filters else [{}])
customer_list=[]
for customer in get_list['customers']:
customer_list.append(customer['id'])
return customer_list


@woo
Expand Down
26 changes: 19 additions & 7 deletions connector_woocommerce/model/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# Tech-Receptives Solutions Pvt. Ltd.
# Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
# Techspwan Solutions Pvt Ltd.
# Copyright (C) 2016-TODAY Techspawn Solutions(<http://www.techspawn.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
Expand Down Expand Up @@ -77,7 +80,7 @@ class ProductProduct(models.Model):
@woo
class ProductProductAdapter(GenericAdapter):
_model_name = 'woo.product.product'
_woo_model = 'products/details'
_woo_model = 'products'

def _call(self, method, arguments):
try:
Expand All @@ -98,7 +101,7 @@ def search(self, filters=None, from_date=None, to_date=None):
"""
if filters is None:
filters = {}
WOO_DATETIME_FORMAT = '%Y/%m/%d %H:%M:%S'
WOO_DATETIME_FORMAT = &# 8000 39;%Y-%m-%d %H:%M:%S'
dt_fmt = WOO_DATETIME_FORMAT
if from_date is not None:
# updated_at include the created records
Expand All @@ -108,8 +111,15 @@ def search(self, filters=None, from_date=None, to_date=None):
filters.setdefault('updated_at', {})
filters['updated_at']['to'] = to_date.strftime(dt_fmt)

return self._call('products/list',
product_count = self._call('products/count',
[filters] if filters else [{}])

get_list = self._call('products?fields=id&filter[limit]='+str(product_count['count'])+'&filter[updated_at_max]='+filters['updated_at']['to'] or None +'&filter[updated_at_min]='+filters['updated_at']['from'] or None,
[filters] if filters else [{}])
product_list=[]
for product in get_list['products']:
product_list.append(product['id'])
return product_list

def get_images(self, id, storeview_id=None):
return self._call('products/' + str(id), [int(id), storeview_id, 'id'])
Expand Down Expand Up @@ -159,9 +169,10 @@ class ProductProductImporter(WooImporter):
def _import_dependencies(self):
""" Import the dependencies for the record"""
record = self.woo_record
record = record['product']
for woo_category_id in record['categories']:
self._import_dependency(woo_category_id,
if 'product' in record.keys():
record = record['product']
for woo_category_id in record['categories']:
self._import_dependency('?filter[name]='+woo_category_id,
'woo.product.category')

def _create(self, data):
Expand Down Expand Up @@ -284,11 +295,12 @@ def categories(self, record):
category_ids = []
main_categ_id = None
for woo_category_id in woo_categories:
cat_id = binder.to_openerp(woo_category_id, unwrap=True)
cat_id = self.env['woo.product.category'].search([('name','=',woo_category_id)])
if cat_id is None:
raise MappingError("The product category with "
"woo id %s is not imported." %
woo_category_id)
cat_id = cat_id[0].id
category_ids.append(cat_id)
if category_ids:
main_categ_id = category_ids.pop(0)
Expand Down
14 changes: 11 additions & 3 deletions connector_woocommerce/model/product_category.py
5D39
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# Tech-Receptives Solutions Pvt. Ltd.
# Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
# Techspwan Solutions Pvt Ltd.
# Copyright (C) 2016-TODAY Techspawn Solutions(<http://www.techspawn.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
Expand Down Expand Up @@ -87,17 +90,21 @@ def search(self, filters=None, from_date=None, to_date=None):
"""
if filters is None:
filters = {}
WOO_DATETIME_FORMAT = '%Y/%m/%d %H:%M:%S'
WOO_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
dt_fmt = WOO_DATETIME_FORMAT
if from_date is not None:
filters.setdefault('updated_at', {})
filters['updated_at']['from'] = from_date.strftime(dt_fmt)
if to_date is not None:
filters.setdefault('updated_at', {})
filters['updated_at']['to'] = to_date.strftime(dt_fmt)
return self._call('products/categories/list',
[filters] if filters else [{}])

get_list = self._call('products/categories?fields=id&filter[limit]=9999&filter[updated_at_max]='+filters['updated_at']['to'] or None +'&filter[updated_at_min]='+filters['updated_at']['from'] or None,
[filters] if filters else [{}])
category_list=[]
for category in get_list['product_categories']:
category_list.append(category['id'])
return category_list

@woo
class CategoryBatchImporter(DelayedBatchImporter):
Expand Down Expand Up @@ -127,6 +134,7 @@ def run(self, filters=None):
filters, record_ids)
for record_id in record_ids:
self._import_record(record_id)

CategoryBatchImporter = CategoryBatchImporter


Expand Down
15 changes: 13 additions & 2 deletions connector_woocommerce/model/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# Tech-Receptives Solutions Pvt. Ltd.
# Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
# Techspwan Solutions Pvt Ltd.
# Copyright (C) 2016-TODAY Techspawn Solutions(<http://www.techspawn.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
Expand Down Expand Up @@ -164,7 +167,7 @@ def search(self, filters=None, from_date=None, to_date=None):
"""
if filters is None:
filters = {}
WOO_DATETIME_FORMAT = '%Y/%m/%d %H:%M:%S'
WOO_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
dt_fmt = WOO_DATETIME_FORMAT
if from_date is not None:
# updated_at include the created records
Expand All @@ -174,8 +177,16 @@ def search(self, filters=None, from_date=None, to_date=None):
filters.setdefault('updated_at', {})
filters['updated_at']['to'] = to_date.strftime(dt_fmt)

return self._call('orders/list',

order_count = self._call('orders/count',
[filters] if filters else [{}])

get_list = self._call('orders?fields=id&filter[limit]='+str(order_count['count'])+'&filter[updated_at_max]='+filters['updated_at']['to'] or None +'&filter[updated_at_min]='+filters['updated_at']['from'] or None,
[filters] if filters else [{}])
order_list=[]
for order in get_list['orders']:
order_list.append(order['id'])
return order_list


@woo
Expand Down
6 changes: 6 additions & 0 deletions connector_woocommerce/unit/backend_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
# Tech-Receptives Solutions Pvt. Ltd.
# Copyright (C) 2009-TODAY Tech-Receptives(<http://www.techreceptives.com>).
#
# Techspwan Solutions Pvt Ltd.
# Copyright (C) 2016-TODAY Techspawn Solutions(<http://www.techspawn.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
Expand Down Expand Up @@ -206,6 +209,9 @@ def read(self, id, attributes=None):
# attributes). The right correction is to install the
# compatibility patch on WooCommerce.
arguments.append(attributes)
if self._woo_model=='products/categories' and type(id)!=int:
categ = self._call('%s' % self._woo_model + str(id), [])
return {'product_category':categ['product_categories'][0]}
return self._call('%s/' % self._woo_model + str(id), [])

def search_read(self, filters=None):
Expand Down
1 change: 0 additions & 1 deletion connector_woocommerce/unit/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#
#


def normalize_datetime(field):
"""Change a invalid date which comes from Woo, if
no real date is set to null for correct import to
Expand Down
0