123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- # -*- coding: utf-8 -*-
- import logging
- from openerp import api, fields, models
- _logger = logging.getLogger(__name__)
- class eiru_pos(models.Model):
- _name = 'eiru.pos'
- # Get company
- @api.model
- def get_company(self):
- user = self.env.user
- return {
- 'id': user.company_id.id,
- 'name': user.company_id.name,
- 'currency': {
- 'id': user.company_id.currency_id.id,
- 'name': user.company_id.currency_id.name,
- 'display_name': user.company_id.currency_id.display_name,
- 'symbol': user.company_id.currency_id.symbol,
- 'format': user.company_id.currency_id.format
- }
- # 'store': {
- # 'id': user.company_id.store_id.id,
- # 'name': user.company_id.store_id.name
- # }
- }
- # Get all products
- @api.model
- def get_products(self):
- domain = [('sale_ok', '=', True), ('active', '=', True)]
- products = []
- for product in self.env['product.template'].search(domain):
- variants = []
- for variant in product.product_variant_ids:
- if not variant.active:
- continue
- attributes = []
- for attribute_line in variant.attribute_line_ids:
- values = []
- for value in attribute_line.value_ids:
- values.append({
- 'id': value.id,
- 'display_name': value.display_name,
- 'name': value.name,
- 'price_extra': value.price_extra
- })
- attributes.append({
- 'id': attribute_line.id,
- 'attribute': {
- 'id': attribute_line.attribute_id.id,
- 'name': attribute_line.attribute_id.name
- },
- 'values': values
- })
-
- variants.append({
- 'id': variant.id,
- 'display_name': variant.display_name,
- 'ean13': variant.ean13,
- 'image_medium': variant.image_medium,
- 'list_price': variant.list_price,
- 'name': variant.name,
- 'qty_available': variant.qty_available,
- 'attributes': attributes
- })
- products.append({
- 'id': product.id,
- 'display_name': product.display_name,
- 'ean13': product.ean13,
- 'image_medium': product.image_medium,
- 'list_price': product.list_price,
- 'name': product.name,
- 'qty_available': product.qty_available,
- 'category': {
- 'id': product.categ_id.id,
- 'display_name': product.categ_id.display_name,
- 'name': product.categ_id.name,
- 'account_journal': {
- 'id': product.categ_id.property_stock_journal.id,
- 'code': product.categ_id.property_stock_journal.code,
- 'company': {
- 'id': product.categ_id.property_stock_journal.company_id.id,
- 'name': product.categ_id.property_stock_journal.company_id.name,
- 'currency': {
- 'id': product.categ_id.property_stock_journal.company_id.currency_id.id,
- 'name': product.categ_id.property_stock_journal.company_id.currency_id.name
- }
- },
- 'currency': {
- 'id': product.categ_id.property_stock_journal.currency.id,
- 'name': product.categ_id.property_stock_journal.currency.name
- },
- 'display_name': product.categ_id.property_stock_journal.display_name,
- 'name': product.categ_id.property_stock_journal.name,
- }
- },
- 'uom': {
- 'id': product.uom_id.id,
- 'name': product.uom_id.name
- },
- 'uos': {
- 'id': product.uos_id.id,
- 'name': product.uos_id.name
- },
- 'variant_count': product.product_variant_count,
- 'variants': variants
- })
- return products
- # Get all currencies
- @api.model
- def get_currencies(self):
- domain = [('active', '=', True)]
- currencies = []
-
- # if self.env.user.store_id:
- # domain.append(('company_id', '=', self.env.user.store_id.company_id.id))
- # else:
- # domain.append(('company_id', '=', self.env.user.company_id.id))
- # print domain
- for currency in self.env['res.currency'].search(domain):
- currencies.append({
- 'id': currency.id,
- 'name': currency.name,
- 'display_name': currency.display_name,
- 'accuracy': currency.accuracy,
- 'base': currency.base,
- 'position': currency.position,
- 'rate': currency.rate,
- 'rounding': currency.rounding,
- 'symbol': currency.symbol,
- 'format': currency.format,
- 'company': {
- 'id': currency.company_id.id,
- 'name': currency.company_id.name
- }
- })
- return currencies
- class eiru_pos_session(models.Model):
- _name = 'eiru.pos.session'
- # Get all sessions
- def get_sessions(self):
- pass
|