123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- # -*- coding: utf-8 -*-
- from openerp import models, fields
- import inspect
- '''
- Users class with token field for manage authentication
- '''
- class res_users(models.Model):
- _inherit = 'res.users'
- jwt_token = fields.Char(string = 'JWT Authentication Token');
- def dump(self):
- return {
- 'id': self.id,
- 'name': self.name,
- 'login': self.login,
- 'email': self.email,
- 'image_small': self.image_small,
- 'image_medium': self.image_medium,
- 'jwt_token': self.jwt_token,
- 'company_id': self.company_id.id,
- 'partner_id': self.partner_id.id,
- }
- '''
- '''
- class res_partner(models.Model):
- _inherit = 'res.partner'
- def dump(self):
- return {
- 'id': self.id,
- 'name': self.name,
- 'display_name': self.display_name,
- 'phone': self.phone,
- 'mobile': self.mobile,
- 'email': self.email,
- 'birthdate': self.birthdate,
- 'city': self.city,
- 'street': self.street,
- 'partner_latitude': self.partner_latitude,
- 'partner_longitude': self.partner_longitude,
- 'image_medium': self.image_medium,
- 'image_small': self.image_small,
- 'comment': self.comment,
- 'phonecall_count': self.phonecall_count,
- 'opportunity_count': self.opportunity_count,
- 'meeting_count': self.meeting_count,
- 'journal_item_count': self.journal_item_count,
- 'sale_order_count': self.sale_order_count,
- 'contracts_count': self.contracts_count,
- 'company_id': self.company_id.id,
- 'country_id': self.country_id.id
- }
- '''
- '''
- class crm_lead(models.Model):
- _inherit = 'crm.lead'
- def dump(self):
- return {
- 'id': self.id,
- 'name': self.name,
- 'display_name': self.display_name,
- 'phone': self.phone,
- 'mobile': self.mobile,
- 'city': self.city,
- 'street': self.street,
- 'street2': self.street2,
- 'partner_name': self.partner_name,
- 'contact_name': self.contact_name,
- 'date_open': self.day_open,
- 'day_close': self.day_close,
- 'day_open': self.day_open,
- 'priority': self.priority,
- 'probability': self.probability,
- 'planned_cost': self.planned_cost,
- 'description': self.description,
- 'meeting_count': self.meeting_count,
- 'partner_id': self.partner_id.id,
- 'company_id': self.company_id.id,
- 'stage_id': self.stage_id.id,
- 'campaign_id': self.campaign_id.id,
- 'country_id': self.country_id.id
- }
- '''
- '''
- class product_template(models.Model):
- _inherit = 'product.template'
- def dump(self):
- return {
- 'active': self.active,
- 'alternative_product_ids': [alt.id for alt in self.alternative_product_ids] if self.alternative_product_ids else [],
- 'attribute_line_ids': [line.id for line in self.attribute_line_ids] if self.attribute_line_ids else [],
- 'color': self.color,
- 'company_id': self.company_id.id if self.company_id.id else None,
- 'categ_id': self.categ_id.id if self.categ_id.id else None,
- 'default_code': self.default_code if self.default_code else None,
- 'description': self.description if self.description else None,
- 'display_name': self.display_name,
- 'ean13': self.ean13 if self.ean13 else None,
- 'factory_barcode': self.factory_barcode if self.factory_reference else None,
- 'factory_reference': self.factory_reference if self.factory_reference else None,
- 'flip_image': self.flip_image if hasattr(self, 'flip_image') else None,
- 'image_medium': self.image_medium,
- 'image_small': self.image_small,
- 'is_flip_image': self.is_flip_image if hasattr(self, 'is_flip_image') else False,
- 'is_product_variant': self.is_product_variant,
- 'list_price': self.list_price,
- 'mes_type': self.mes_type,
- 'multiple_image': self.multiple_image if hasattr(self, 'multiple_image') else False,
- 'name': self.name,
- 'price': self.price,
- 'product_variant_count': self.product_variant_count,
- 'product_variant_ids': [variant.id for variant in self.product_variant_ids] if self.product_variant_ids else [],
- 'purchase_ok': self.purchase_ok if hasattr(self, 'purchase_ok') else False,
- 'qty_available': self.qty_available if hasattr(self, 'qty_available') else 0,
- 'rental': self.rental if hasattr(self, 'rental') else False,
- 'sale_ok': self.sale_ok if hasattr(self, 'sale_ok') else False,
- 'type': self.type if hasattr(self, 'type') else None,
- 'website_published': self.website_published if hasattr(self, 'website_published') else False
- }
- '''
- '''
- class product_attribute_line(models.Model):
- _inherit = 'product.attribute.line'
- def dump(self):
- return {
- 'attribute_id': self.attribute_id.id if self.attribute_id.id else None,
- 'create_date': self.create_date,
- 'display_name': self.display_name,
- 'id': self.id,
- 'product_tmpl_id': self.product_tmpl_id.id if self.product_tmpl_id.id else None,
- 'value_ids': [value.id for value in self.value_ids] if self.value_ids else []
- }
- '''
- '''
- class product_attribute(models.Model):
- _inherit = 'product.attribute'
- def dump(self):
- return {
- 'active': self.active,
- 'create_date': self.create_date,
- 'display_name': self.display_name,
- 'id': self.id,
- 'name': self.name,
- 'type': self.type,
- 'value_ids': [value.id for value in self.value_ids] if self.value_ids else []
- }
- '''
- '''
- class product_attribute_price(models.Model):
- _inherit = 'product.attribute.price'
- def dump(self):
- attributes = inspect(self, lambda a:not(isroutine(a)))
- print '----------------------------------------------------------------'
- print attributes
- print '----------------------------------------------------------------'
-
- return {
- 'response': 'ok'
- }
- '''
- '''
- class product_attribute_value(models.Model):
- _inherit = 'product.attribute.value'
- def dump(self):
- return {
- 'attribute_id': self.attribute_id.id if self.attribute_id.id else None,
- 'color': self.color if self.color else None,
- 'create_date': self.create_date,
- 'display_name': self.display_name,
- 'id': self.id,
- 'name': self.name,
- 'price_extra': self.price_extra,
- 'price_ids': [price.id for price in self.price_ids] if self.price_ids else [],
- 'product_ids': [product.id for product in self.product_ids] if self.product_ids else []
- }
- '''
- '''
- class product_product(models.Model):
- _inherit = 'product.product'
- def dump(self):
- return {
- 'active': self.active,
- 'alternative_product_ids': [alternative.id for alternative in self.alternative_product_ids] if self.alternative_product_ids else [],
- 'attribute_line_ids': [alt.id for alt in self.attribute_line_ids] if self.attribute_line_ids else [],
- 'attribute_value_ids': [value.id for value in self.attribute_value_ids] if self.attribute_value_ids else [],
- 'categ_id': self.categ_id.id if self.categ_id else None,
- 'code': self.code,
- 'company_id': self.company_id.id if self.company_id else None,
- 'create_date': self.create_date,
- 'default_code': self.default_code if self.default_code else None,
- 'description': self.description if self.description else None,
- 'display_name': self.display_name,
- 'ean13': self.ean13 if self.ean13 else None,
- 'factory_barcode': self.factory_barcode if self.factory_barcode else None,
- 'factory_reference': self.factory_reference if self.factory_reference else None,
- 'image_medium': self.image_medium,
- 'image_small': self.image_small,
- 'image_variant': self.image_variant,
- 'id': self.id,
- 'is_product_variant': self.is_product_variant,
- 'list_price': self.list_price,
- 'name': self.name,
- 'name_template': self.name_template,
- 'price': self.price,
- 'price_extra': self.price_extra,
- 'product_tmpl_id': self.product_tmpl_id.id if self.product_tmpl_id else None,
- 'product_variant_count': self.product_variant_count,
- 'product_variant_ids': [variant.id for variant in self.product_variant_ids] if self.product_variant_ids else []
- }
|