Exemplo n.º 1
0
 def unpublish_from_master(self):
     db_master = config.get('db_master')
     model = self.env.context.get('master_model', self._name)
     domain = [('name', '=', self.name)]
     oids = connector.call(db_master, model, 'search', domain)
     res = connector.call(db_master, model, 'unlink', oids)
     if res:
         self.write({'published': False})
     return res
Exemplo n.º 2
0
 def unpublish_from_master(self):
     db_master = config.get('db_master')
     model = self.env.context.get('master_model', self._name)
     domain = [('name', '=', self.name)]
     oids = connector.call(db_master, model, 'search', domain)
     res = connector.call(db_master, model, 'unlink', oids)
     if res:
         self.write({'published': False})
     return res
Exemplo n.º 3
0
 def create_template(self, cr, uid, ids, context=None):
     obj = self.browse(cr, uid, ids[0])
     openerp.service.db.exp_create_database(obj.template, obj.demo, 'en_US')
     addon_names = [x.name for x in obj.required_addons_ids]
     if 'saas_client' not in addon_names:
         addon_names.append('saas_client')
     to_search = [('name', 'in', addon_names)]
     addon_ids = connector.call(obj.template, 'ir.module.module',
                                'search', to_search)
     for addon_id in addon_ids:
         connector.call(obj.template, 'ir.module.module',
                        'button_immediate_install', addon_id)
     return self.write(cr, uid, obj.id, {'state': 'confirmed'})
Exemplo n.º 4
0
 def create_template(self, cr, uid, ids, context=None):
     obj = self.browse(cr, uid, ids[0])
     openerp.service.db.exp_create_database(obj.template, obj.demo, 'en_US')
     addon_names = [x.name for x in obj.required_addons_ids]
     if 'saas_client' not in addon_names:
         addon_names.append('saas_client')
     to_search = [('name', 'in', addon_names)]
     addon_ids = connector.call(obj.template, 'ir.module.module', 'search',
                                to_search)
     for addon_id in addon_ids:
         connector.call(obj.template, 'ir.module.module',
                        'button_immediate_install', addon_id)
     return self.write(cr, uid, obj.id, {'state': 'confirmed'})
Exemplo n.º 5
0
 def select_products(self, cr, uid, ids, context=None):
     obj_ids = self.pull_from_catalog(cr, uid, ids[0])
     obj = self.browse(cr, uid, obj_ids[0])
     pt = self.pool.get('product.template.commodity')
     product_ids = connector.call(config.get('db_master'),
                                  'product.template.commodity', 'search',
                                  [('seller_id', '=', ids[0])])
     lines = []
     for pid in product_ids:
         lpid = pt.pull_from_catalog(cr, uid, pid)
         product = pt.browse(cr, uid, lpid[0])
         lines.append((0, 0, {
             'product_commodity_id': product.id,
             'variant_commodity_id': product.variant_ids[0].id,
             'quantity': product.variant_ids[0].moq
         }))
     vals = {'name': obj.name, 'partner_id': obj.id, 'line_ids': lines}
     ptr_id = self.pool.get('partner.to.request').create(cr, uid, vals)
     return {
         'type': 'ir.actions.act_window',
         'view_type': 'form',
         'view_mode': 'form',
         'res_model': 'partner.to.request',
         'res_id': ptr_id,
         'target': 'new'
     }
Exemplo n.º 6
0
 def select_products(self, cr, uid, ids, context=None):
     obj_ids = self.pull_from_catalog(cr, uid, ids[0])
     obj = self.browse(cr, uid, obj_ids[0])
     pt = self.pool.get("product.template.commodity")
     product_ids = connector.call(
         config.get("db_master"), "product.template.commodity", "search", [("seller_id", "=", ids[0])]
     )
     lines = []
     for pid in product_ids:
         lpid = pt.pull_from_catalog(cr, uid, pid)
         product = pt.browse(cr, uid, lpid[0])
         lines.append(
             (
                 0,
                 0,
                 {
                     "product_commodity_id": product.id,
                     "variant_commodity_id": product.variant_ids[0].id,
                     "quantity": product.variant_ids[0].moq,
                 },
             )
         )
     vals = {"name": obj.name, "partner_id": obj.id, "line_ids": lines}
     ptr_id = self.pool.get("partner.to.request").create(cr, uid, vals)
     return {
         "type": "ir.actions.act_window",
         "view_type": "form",
         "view_mode": "form",
         "res_model": "partner.to.request",
         "res_id": ptr_id,
         "target": "new",
     }
Exemplo n.º 7
0
 def pull_from_catalog_by(self, cr, uid, field, value):
     domain = [(field, '=', value)]
     oids = connector.call(config.get('db_master'), self._name, 'search',
                           domain)
     if not oids:
         raise ValidationError('''It could not find the object %s
                                 in catalog''' % value)
     return self.pull_from_catalog(cr, uid, oids[0])
Exemplo n.º 8
0
 def exists_partner(self):
     assert hasattr(self,
                    'partner_id'), "The object doesn't have partner_id"
     data = connector.call(config.get('db_master'), 'res.users',
                           'search_read',
                           [('organization', '=', self.partner_id.name)],
                           ['database', 'partner_id'])
     return data and data[0] or False
Exemplo n.º 9
0
 def onchange_partner_in_marketplace(self):
     if self.partner_id:
         domain = [('seller_id.name', '=', self.partner_id.name)]
         pids = connector.call(config.get('db_master'),
                               'product.template.commodity', 'search',
                               domain)
         for pid in pids:
             self.env['product.template.commodity'].pull_from_catalog(pid)
Exemplo n.º 10
0
 def search_read(self, cr, uid, domain=None, fields=None, offset=0,
                 limit=None, order=None, context=None):
     args = (domain, fields, offset, limit, order, context)
     context = context or {}
     if context.get('catalog_db', False):
         db = config.get(context['catalog_db'])
         return connector.call(db, self._name, 'search_read', *args)
     return super(CatalogMixin, self).search_read(cr, uid, *args)
Exemplo n.º 11
0
 def pull_from_catalog_by(self, cr, uid, field, value):
     domain = [(field, '=', value)]
     oids = connector.call(config.get('db_master'), self._name, 'search',
                           domain)
     if not oids:
         raise ValidationError('''It could not find the object %s
                                 in catalog''' % value)
     return self.pull_from_catalog(cr, uid, oids[0])
Exemplo n.º 12
0
 def read_group(self, cr, uid, domain, fields, groupby, offset=0,
                limit=None, context=None, orderby=False, lazy=True):
     args = (domain, fields, groupby, offset, limit, context, orderby, lazy)
     context = context or {}
     if context.get('catalog_db', False):
         db = config.get(context['catalog_db'])
         return connector.call(db, self._name, 'read_group', *args)
     return super(CatalogMixin, self).read_group(cr, uid, *args)
Exemplo n.º 13
0
 def onchange_partner_in_marketplace(self):
     if self.partner_id:
         domain = [('seller_id.name', '=', self.partner_id.name)]
         pids = connector.call(config.get('db_master'),
                               'product.template.commodity',
                               'search', domain)
         for pid in pids:
             self.env['product.template.commodity'].pull_from_catalog(pid)
Exemplo n.º 14
0
 def read(self, cr, uid, ids, fields=None, context=None,
          load='_classic_read'):
     args = (ids, fields, context, load)
     context = context or {}
     if context.get('catalog_db', False):
         db = config.get(context['catalog_db'])
         res = connector.call(db, self._name, 'read', *args)
         return res
     return super(CatalogMixin, self).read(cr, uid, *args)
Exemplo n.º 15
0
 def publish_to_partner(self):
     if not self.env.context.get('partner_db', False):
         assert hasattr(self, 'partner_id'), "Field partner_id not present."
         data = connector.call(
             config.get('db_master'), 'res.users', 'search_read',
             [('organization', '=', self.partner_id.name)], ['database'])
         if not data:
             return False
         db = data[0]['database']
     return self.with_context(partner_db=db).publish()
Exemplo n.º 16
0
 def publish_to_partner(self):
     if not self.env.context.get('partner_db', False):
         assert hasattr(self, 'partner_id'), "Field partner_id not present."
         data = connector.call(config.get('db_master'),
                               'res.users', 'search_read',
                               [('organization', '=', self.partner_id.name)],
                               ['database'])
         if not data:
             return False
         db = data[0]['database']
     return self.with_context(partner_db=db).publish()
Exemplo n.º 17
0
 def read(self,
          cr,
          uid,
          ids,
          fields=None,
          context=None,
          load='_classic_read'):
     args = (ids, fields, context, load)
     context = context or {}
     if context.get('catalog_db', False):
         db = config.get(context['catalog_db'])
         res = connector.call(db, self._name, 'read', *args)
         return res
     return super(CatalogMixin, self).read(cr, uid, *args)
Exemplo n.º 18
0
 def search_read(self,
                 cr,
                 uid,
                 domain=None,
                 fields=None,
                 offset=0,
                 limit=None,
                 order=None,
                 context=None):
     args = (domain, fields, offset, limit, order, context)
     context = context or {}
     if context.get('catalog_db', False):
         db = config.get(context['catalog_db'])
         return connector.call(db, self._name, 'search_read', *args)
     return super(CatalogMixin, self).search_read(cr, uid, *args)
Exemplo n.º 19
0
 def read_group(self,
                cr,
                uid,
                domain,
                fields,
                groupby,
                offset=0,
                limit=None,
                context=None,
                orderby=False,
                lazy=True):
     args = (domain, fields, groupby, offset, limit, context, orderby, lazy)
     context = context or {}
     if context.get('catalog_db', False):
         db = config.get(context['catalog_db'])
         return connector.call(db, self._name, 'read_group', *args)
     return super(CatalogMixin, self).read_group(cr, uid, *args)
Exemplo n.º 20
0
 def exists_partner(self):
     assert hasattr(self, 'partner_id'), "The object doesn't have partner_id"
     data = connector.call(config.get('db_master'), 'res.users', 'search_read',
                           [('organization', '=', self.partner_id.name)],
                           ['database', 'partner_id'])
     return data and data[0] or False
Exemplo n.º 21
0
 def search_in_catalog(self, cr, uid, name):
     res = connector.call(config.get('db_master'), self._name, 'search',
                          [('name', '=', name)])
     return res and res[0] or False
Exemplo n.º 22
0
 def pull_from_catalog(self, cr, uid, oid):
     wh = self.pool.get('cenit.handler')
     vals = connector.call(config.get('db_master'), 'cenit.serializer',
                           'serialize_model_id', self._name, oid)
     return wh.add(cr, 1, vals, self._get_root(cr, uid, self._name))
Exemplo n.º 23
0
 def pull_from_catalog(self, cr, uid, oid):
     wh = self.pool.get('cenit.handler')
     vals = connector.call(config.get('db_master'), 'cenit.serializer',
                           'serialize_model_id', self._name, oid)
     return wh.add(cr, 1, vals, self._get_root(cr, uid, self._name))
Exemplo n.º 24
0
 def search_in_catalog(self, cr, uid, name):
     res = connector.call(config.get('db_master'), self._name, 'search',
                          [('name', '=', name)])
     return res and res[0] or False
Exemplo n.º 25
0
 def _get_commodity_data(self, ids):
     db = config.get('db_master')
     domain = [('id', '=', ids[0])]
     fields = ['product_commodity_id', 'variant']
     return connector.call(db, self._name, 'search_read', domain, fields)
Exemplo n.º 26
0
 def _get_commodity_data(self, ids):
     db = config.get('db_master')
     domain = [('id', '=', ids[0])]
     fields = ['product_commodity_id', 'variant']
     return connector.call(db, self._name, 'search_read', domain, fields)