[IMP] website, *: implement some "add new content" actions
*: website_sale, website_hr_recruitment See merge commit for more information. task-2687506
This commit is contained in:
@@ -120,26 +120,6 @@
|
||||
<p>Forum</p>
|
||||
</a>
|
||||
</div>
|
||||
<t t-set="mod" t-value="env.ref('base.module_website_hr_recruitment')"/>
|
||||
<div name="module_website_hr_recruitment" t-if='is_system' t-cache="is_system"
|
||||
t-att-data-module-id="mod.id"
|
||||
t-att-data-module-shortdesc="mod.shortdesc"
|
||||
class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#">
|
||||
<i class="fa fa-briefcase"/>
|
||||
<p>Job Offer</p>
|
||||
</a>
|
||||
</div>
|
||||
<t t-set="mod" t-value="env.ref('base.module_website_sale')"/>
|
||||
<div name="module_website_sale" t-if='is_system' t-cache="is_system"
|
||||
t-att-data-module-id="mod.id"
|
||||
t-att-data-module-shortdesc="mod.shortdesc"
|
||||
class="col-md-4 mb8 o_new_content_element">
|
||||
<a href="#" data-action="new_product">
|
||||
<i class="fa fa-shopping-cart"/>
|
||||
<p>Product</p>
|
||||
</a>
|
||||
</div>
|
||||
<t t-set="mod" t-value="env.ref('base.module_website_slides')"/>
|
||||
<div name="module_website_slides" t-if='is_system' t-cache="is_system"
|
||||
t-att-data-module-id="mod.id"
|
||||
|
||||
@@ -12,5 +12,7 @@ patch(NewContentModal.prototype, 'website_hr_recruitment_new_content', {
|
||||
newJobElement.status = MODULE_STATUS.INSTALLED;
|
||||
},
|
||||
|
||||
async createNewJob() {}
|
||||
createNewJob() {
|
||||
this.website.goToWebsite({ path: '/jobs/add' });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -593,18 +593,4 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- User Navbar -->
|
||||
<template id="user_navbar_inherit_website_hr_recruitment" inherit_id="website.user_navbar">
|
||||
<xpath expr="//div[@id='o_new_content_menu_choices']//div[@name='module_website_hr_recruitment']/a" position="attributes">
|
||||
<attribute name="href">/jobs/add</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//div[@id='o_new_content_menu_choices']//div[@name='module_website_hr_recruitment']" position="attributes">
|
||||
<attribute name="name"/>
|
||||
<attribute name="t-att-data-module-id"/>
|
||||
<attribute name="t-att-data-module-shortdesc"/>
|
||||
<attribute name="t-if">is_designer</attribute>
|
||||
<attribute name="t-cache"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
|
||||
@@ -2,6 +2,39 @@
|
||||
|
||||
import { NewContentModal, MODULE_STATUS } from '@website/systray_items/new_content';
|
||||
import { patch } from 'web.utils';
|
||||
import { WebsiteDialog } from '@website/components/dialog/dialog';
|
||||
|
||||
const { xml, useState } = owl;
|
||||
|
||||
export class AddProductDialog extends WebsiteDialog {
|
||||
setup() {
|
||||
super.setup();
|
||||
|
||||
this.title = this.env._t("New Product");
|
||||
this.primaryTitle = this.env._t("Create");
|
||||
|
||||
this.state = useState({
|
||||
name: '',
|
||||
});
|
||||
}
|
||||
|
||||
async primaryClick() {
|
||||
await this.props.addProduct(this.state.name);
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
AddProductDialog.bodyTemplate = xml`
|
||||
<div>
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-3">
|
||||
Product Name
|
||||
</label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" t-model="state.name" class="form-control" required="required"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
patch(NewContentModal.prototype, 'website_sale_new_content', {
|
||||
setup() {
|
||||
@@ -12,5 +45,14 @@ patch(NewContentModal.prototype, 'website_sale_new_content', {
|
||||
newProductElement.status = MODULE_STATUS.INSTALLED;
|
||||
},
|
||||
|
||||
createNewProduct() {}
|
||||
createNewProduct() {
|
||||
this.dialogs.add(AddProductDialog, {
|
||||
addProduct: async (name) => {
|
||||
const url = await this.rpc('/shop/add_product', {
|
||||
name,
|
||||
});
|
||||
this.website.goToWebsite({ path: url });
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,52 +1,3 @@
|
||||
odoo.define('website_sale.add_product', function (require) {
|
||||
'use strict';
|
||||
|
||||
var core = require('web.core');
|
||||
var wUtils = require('website.utils');
|
||||
var WebsiteNewMenu = require('website.newMenu');
|
||||
|
||||
var _t = core._t;
|
||||
|
||||
WebsiteNewMenu.include({
|
||||
actions: _.extend({}, WebsiteNewMenu.prototype.actions || {}, {
|
||||
new_product: '_createNewProduct',
|
||||
}),
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Actions
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Asks the user information about a new product to create, then creates it
|
||||
* and redirects the user to this new product.
|
||||
*
|
||||
* @private
|
||||
* @returns {Promise} Unresolved if there is a redirection
|
||||
*/
|
||||
_createNewProduct: function () {
|
||||
var self = this;
|
||||
return wUtils.prompt({
|
||||
id: "editor_new_product",
|
||||
window_title: _t("New Product"),
|
||||
input: _t("Product Name"),
|
||||
}).then(function (result) {
|
||||
if (!result.val) {
|
||||
return;
|
||||
}
|
||||
return self._rpc({
|
||||
route: '/shop/add_product',
|
||||
params: {
|
||||
name: result.val,
|
||||
},
|
||||
}).then(function (url) {
|
||||
window.location.href = url;
|
||||
return new Promise(function () {});
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
odoo.define('website_sale.editMenu', function (require) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -1985,17 +1985,6 @@
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- User Navbar -->
|
||||
<template id="user_navbar_inherit_website_sale" inherit_id="website.user_navbar">
|
||||
<xpath expr="//div[@id='o_new_content_menu_choices']//div[@name='module_website_sale']" position="attributes">
|
||||
<attribute name="name"/>
|
||||
<attribute name="t-att-data-module-id"/>
|
||||
<attribute name="t-att-data-module-shortdesc"/>
|
||||
<attribute name="t-if">env.user.has_group('sales_team.group_sale_manager')</attribute>
|
||||
<attribute name="t-cache"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="sale_order_portal_content_inherit_website_sale" name="Orders Followup Products Links" inherit_id="sale.sale_order_portal_content">
|
||||
<xpath expr="//section[@id='details']//td[@id='product_name']/*" position="replace">
|
||||
<a t-if="line.product_id.website_published" t-att-href="line.product_id.website_url">
|
||||
|
||||
Reference in New Issue
Block a user