|
@@ -208,7 +208,24 @@ class Purchases(http.Controller):
|
|
|
@http.route('/eiru_purchases/create_supplier', type='json', auth='user', methods=['POST'], cors='*')
|
|
|
def create_supplier(self, **kw):
|
|
|
self.make_info_log('Creating supplier')
|
|
|
- print(kw)
|
|
|
+
|
|
|
+ supplier = request.env['res.partner'].create({
|
|
|
+ 'name': kw.get('name'),
|
|
|
+ 'ruc': kw.get('ruc'),
|
|
|
+ 'phone': kw.get('phone'),
|
|
|
+ 'supplier': True,
|
|
|
+ 'customer': False
|
|
|
+ })
|
|
|
+
|
|
|
+ return {
|
|
|
+ 'id': supplier.id,
|
|
|
+ 'name': supplier.name,
|
|
|
+ 'displayName': supplier.display_name,
|
|
|
+ 'imageMedium': supplier.image_medium,
|
|
|
+ 'phone': supplier.phone,
|
|
|
+ 'mobile': supplier.mobile,
|
|
|
+ 'email': supplier.email
|
|
|
+ }
|
|
|
|
|
|
'''
|
|
|
Create product and return data
|
|
@@ -216,7 +233,30 @@ class Purchases(http.Controller):
|
|
|
@http.route('/eiru_purchases/create_product', type='json', auth='user', methods=['POST'], cors='*')
|
|
|
def create_product(self, **kw):
|
|
|
self.make_info_log('Creating product')
|
|
|
- print(kw)
|
|
|
+
|
|
|
+ product = request.env['product.template'].create({
|
|
|
+ 'name': kw.get('name'),
|
|
|
+ 'standard_price': float(kw.get('price')),
|
|
|
+ 'ean13': kw.get('ean13')
|
|
|
+ })
|
|
|
+
|
|
|
+ return {
|
|
|
+ 'id': product.id,
|
|
|
+ 'name': product.name,
|
|
|
+ 'displayName': product.display_name,
|
|
|
+ 'ean13': product.ean13,
|
|
|
+ 'imageMedium': product.image_medium,
|
|
|
+ 'listPrice': product.list_price,
|
|
|
+ 'variantCount': product.product_variant_count,
|
|
|
+ 'variants': [{
|
|
|
+ 'id': variant.id,
|
|
|
+ 'name': variant.name,
|
|
|
+ 'displayName': variant.display_name,
|
|
|
+ 'ean13': variant.ean13,
|
|
|
+ 'imageMedium': variant.image_medium,
|
|
|
+ 'listPrice': variant.list_price
|
|
|
+ } for variant in product.product_variant_ids if variant.active]
|
|
|
+ }
|
|
|
|
|
|
'''
|
|
|
Create purchase resource route
|