示例#1
0
 def open_content_url(self):
     return {
         'name': 'Go to website',
         'res_model': 'ir.actions.act_url',
         'type': 'ir.actions.act_url',
         'url': 'news/' + slugify(self)
     }
示例#2
0
    def _compute_variant_url(self):

        if self.variant_id:
            url = '/shop/variant/%s-%s' % (slugify(self.variant_id.name), self.variant_id.id)
            self.variant_url = url
        else:
            self.variant_url = False
示例#3
0
 def new_page(self,
              name=False,
              add_menu=False,
              template='website.default_page',
              ispage=True,
              namespace=None):
     res = super(website, self).new_page(name=name,
                                         add_menu=add_menu,
                                         template=template,
                                         ispage=ispage,
                                         namespace=namespace)
     page_name = slugify(name, max_length=50)
     ir_view = self.env['ir.ui.view']
     view_id = self.env['ir.ui.view'].search([('name', '=', res)])
     if view_id:
         view = ir_view.browse(SUPERUSER_ID, view_id)
         arch = '<?xml version="1.0"?><t t-name="website.' + str(
             page_name
         ) + '"><t t-call="website.layout"> <div id="wrap" class="oe_structure oe_empty"><section class="page-title"><div class="container"><h1>' + str(
             page_name.capitalize()
         ) + '</h1><ul class="breadcrumb"><li><a href="/page/homepage">Home</a></li><li class="active">' + str(
             page_name.capitalize(
             )) + '</li></ul></div></section></div></t></t>'
         ir_view.write(SUPERUSER_ID, view_id, {'arch': arch})
     return res
示例#4
0
    def compare_purchase_orders(self):
        context = dict(self._context or {})
        active_ids = context.get('active_ids', []) or []
        purchase_orders_id = self.env['purchase.order'].search([("id", "in",
                                                                 active_ids)])
        vendor_list = []
        for rec in purchase_orders_id:
            if not rec.partner_id in vendor_list:
                vendor_list.append(rec.partner_id)
            else:
                raise UserError(
                    _('Same Vendors should not be selected, Please select different vendors for Purchase Comparison'
                      ))

        purchase_orders = self.env['purchase.order'].browse(self.ids)
        if len(purchase_orders) == 0:
            raise UserError(
                _('No RFQ available for compare. Please add some RFQ to compare'
                  ))
        purchase_orders = self.env['purchase.order'].search([
            ('id', 'in', self.ids), ('state', '=', 'draft')
        ])

        if not purchase_orders:
            raise UserError(
                _('All RFQs are processed. Please create new quotation'))
        base_url = '/' if self.env.context.get(
            'relative_url') else self.env['ir.config_parameter'].get_param(
                'web.base.url')

        list_id = False
        for record in purchase_orders:
            list_id = record.product_list_id
        if not list_id:
            redirect_url = "purchase_comparison_chart/purchase_comparison_product_list/po/%s" % (
                slugify(active_ids))
        else:
            redirect_url = "purchase_comparison_chart/purchase_comparison_product_list/%s" % (
                slugify(list_id.id))

        return {
            'type': 'ir.actions.act_url',
            'name': "Purchase Comparison Chart",
            'target': 'self',
            'url': redirect_url
        }
示例#5
0
 def _compute_url(self):
     """ Computes a public URL for the purchase comparison """
     base_url = '/' if self.env.context.get(
         'relative_url') else self.env['ir.config_parameter'].get_param(
             'web.base.url')
     for record in self:
         record.print_url = urljoin(
             base_url, "purchase_comparison_chart/purchase_comparison/%s" %
             (slugify(record)))
示例#6
0
 def _check_seo_url(self, vals, record_id=0):
     field = self._seo_url_field
     vals = vals or {}
     value = vals.get(field)
     if value:
         vals[field] = value = slugify(value)
         res = self.search([(field, "=", value), ("id", "!=", record_id)])
         if res:
             vals[field] = "{}-{}".format(vals[field], record_id)
     return vals
示例#7
0
 def _check_seo_url(self, vals, id=0):
     field = self._seo_url_field
     vals = vals or {}
     value = vals.get(field)
     if value:
         vals[field] = value = slugify(value)
         res = self.search([(field, '=', value), ('id', '!=', id)])
         if res:
             vals[field] = '%s-%s' % (vals[field], id)
     return vals
示例#8
0
文件: base.py 项目: simahawk/odoo-dj
    def _dj_xmlid_export_name(self):
        """Customize xmlid name for dj compilation.

        You can specify field names by model name
        into context variable `dj_xmlid_fields_map`
        to be used for xmlid generation.
        Strings will be normalized.
        """
        name = [self._table, str(self.id)]  # std odoo default
        mapping = self.env.context.get('dj_xmlid_fields_map') or {}
        global_config = self._dj_global_config()
        xmlid_fields = (mapping.get(self._name, []) or
                        global_config.get('xmlid_fields', []))
        if not xmlid_fields and 'name' in self:
            # No specific configuration: we assume we can use name as default
            xmlid_fields.append('name')
        if xmlid_fields:
            name = [self._table, ]
            if global_config.get('xmlid_table_name'):
                name = [global_config['xmlid_table_name'], ]
            for key in xmlid_fields:
                if not self[key]:
                    continue
                value = self[key]
                if isinstance(value, basestring):
                    value = slugify(value).replace('-', '_')
                elif isinstance(value, models.BaseModel):
                    value = slugify(value.display_name).replace('-', '_')
                elif isinstance(value, (int, float)):
                    value = str(value)
                name.append(value)
        if (self.env.context.get('dj_multicompany') and
                'company_id' in self and self.company_id.aka):
            # discriminate by company `aka` code
            name.insert(0, self.company_id.normalized_aka())
        return '_'.join(name)
示例#9
0
    def new_report(self, name, object_name=False, layout=False):
        templates = self.env['ir.ui.view'].search([('key', 'ilike', 'report_designer_73lines.default_report')], order='id asc')
        report_xmlid = False
        uq_key = str(uuid.uuid4()).replace('-', '')[:8]
        report_name = slugify(name, max_length=50) + "-" + uq_key
        template_module = report_name.replace('-', '_')

        for template in templates:
            report_xmlid = self.env['report.designer'].copy_template_data(template, template_module, report_name, object_name, layout)

        self.env['ir.module.module'].create({
            "name": template_module,
            "shortdesc": name,
            "application": False,
            "icon": "/base/static/description/icon.png",
            "description": "Export report using Report Designer",
            "state": "installed",
            "author": self.env.user.company_id.name,
        })

        return report_xmlid
示例#10
0
 def test_underscore(self):
     self.assertEqual(
         "one-two",
         slugify(u"one_two")
     )
 def _onchange_mailing_slug(self):
     if self.mailing_slug:
         self.mailing_slug = slugify(self.mailing_slug)
示例#12
0
文件: utils.py 项目: simahawk/odoo-dj
def make_title(name):
    dt = datetime.datetime.now().strftime('%Y%m%d_%H%M')
    return '{}-{}.zip'.format(slugify(name).replace('-', '_'), dt)
示例#13
0
 def test_all(self):
     self.assertEqual(
         "do-you-know-martine-a-la-plage",
         slugify(u"Do YOU know 'Martine à la plage' ?")
     )
示例#14
0
 def test_numbers(self):
     self.assertEqual(
         "article-1",
         slugify(u"Article 1")
     )
示例#15
0
 def test_str_to_unicode(self):
     self.assertEqual(
         "espana",
         slugify("España")
     )
示例#16
0
 def test_special_chars(self):
     self.assertEqual(
         "o-d-o-o",
         slugify(u"o!#d{|\o/@~o&%^?")
     )
示例#17
0
 def write(self, vals):
     if vals.get('name'):
         vals['name'] = slugify(vals['name']).replace('-', '_')
     return super(Genre, self).write(vals)
示例#18
0
 def test_unicode(self):
     self.assertEqual(
         "heterogeneite",
         slugify(u"hétérogénéité")
     )
示例#19
0
 def test_spaces(self):
     self.assertEqual(
         "spaces",
         slugify(u"   spaces   ")
     )
示例#20
0
 def normalized_aka(self):
     if not self.aka:
         return ''
     return slugify(self.aka).replace('-', '_')
示例#21
0
    def _compute_product_url(self):

        url = '/shop/subscription/%s-%s' % (slugify(self.name), self.id)

        self.product_url = url
示例#22
0
 def test_caps(self):
     self.assertEqual(
         "camelcase",
         slugify(u"CamelCase")
     )
示例#23
0
 def _compute_website_url(self):
     super(Display, self)._compute_website_url()
     for display in self:
         display.website_url = "/smartdisplay/display/%s" % (slugify(display))