[IMP] Lunch: Archive products
Add a stat/toggle button on form view Add a stat/toggle action on tree view
This commit is contained in:
@@ -17,7 +17,7 @@ class LunchOrder(models.Model):
|
||||
_order = 'date desc'
|
||||
|
||||
def _default_previous_order_ids(self):
|
||||
prev_order = self.env['lunch.order.line'].search([('user_id', '=', self.env.uid)], limit=20, order='id desc')
|
||||
prev_order = self.env['lunch.order.line'].search([('user_id', '=', self.env.uid), ('product_id.active', '!=', False)], limit=20, order='id desc')
|
||||
# If we return return prev_order.ids, we will have duplicates (identical orders).
|
||||
# Therefore, this following part removes duplicates based on product_id and note.
|
||||
return {
|
||||
@@ -194,6 +194,7 @@ class LunchProduct(models.Model):
|
||||
description = fields.Text('Description')
|
||||
price = fields.Float('Price', digits=dp.get_precision('Account'))
|
||||
supplier = fields.Many2one('res.partner', 'Vendor')
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
|
||||
class LunchProductCategory(models.Model):
|
||||
@@ -245,6 +246,7 @@ class LunchAlert(models.Model):
|
||||
sunday = fields.Boolean('Sunday')
|
||||
start_hour = fields.Float('Between', oldname='active_from', required=True, default=7)
|
||||
end_hour = fields.Float('And', oldname='active_to', required=True, default=23)
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
@api.multi
|
||||
def name_get(self):
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search">
|
||||
<field name="message"/>
|
||||
<filter name="inactive" string="Archived" domain="[('active','=',False)]"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
@@ -434,6 +435,25 @@
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="ir_actions_server_lunch_archive_product" model="ir.actions.server">
|
||||
<field name="name">Archive/Unarchive</field>
|
||||
<field name="condition">True</field>
|
||||
<field name="type">ir.actions.server</field>
|
||||
<field name="model_id" ref="model_lunch_product" />
|
||||
<field name="state">code</field>
|
||||
<field name="code">self.toggle_active(cr, uid, context.get('active_ids', []), context=context)</field>
|
||||
</record>
|
||||
|
||||
<record id="ir_values_lunch_archive_product" model="ir.values">
|
||||
<field name="name">action_lunch_archive_product</field>
|
||||
<field name="action_id" ref="action_server_lunch_archive_product" />
|
||||
<field name="value" eval="'ir.actions.server,' + str(ref('action_server_lunch_archive_product'))"/>
|
||||
<field name="key">action</field>
|
||||
<field name="model_id" ref="model_lunch_product" />
|
||||
<field name="model">lunch.product</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
</record>
|
||||
|
||||
<!-- Search for product -->
|
||||
<record id="lunch_product_view_search" model="ir.ui.view">
|
||||
<field name="name">lunch.product.search</field>
|
||||
@@ -447,6 +467,7 @@
|
||||
<group expand="0" string="Group By">
|
||||
<filter name="supplier" string="Vendor" context="{'group_by': 'supplier'}"/>
|
||||
<filter name="category" string="Category" context="{'group_by': 'category_id'}"/>
|
||||
<filter name="inactive" string="Archived" domain="[('active','=',False)]"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
@@ -459,18 +480,27 @@
|
||||
<form string="Products Form">
|
||||
<header>
|
||||
</header>
|
||||
<group>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="toggle_active" type="object"
|
||||
class="oe_stat_button" icon="fa-archive">
|
||||
<field name="active" widget="boolean_button"
|
||||
options='{"terminology": "archive"}'/>
|
||||
</button>
|
||||
</div>
|
||||
<group>
|
||||
<field name='name'/>
|
||||
<field name='category_id'/>
|
||||
<group>
|
||||
<field name='name'/>
|
||||
<field name='category_id'/>
|
||||
</group>
|
||||
<group>
|
||||
<field name='supplier'/>
|
||||
<field name='price'/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<field name='supplier'/>
|
||||
<field name='price'/>
|
||||
</group>
|
||||
</group>
|
||||
<label for='description'/>
|
||||
<field name='description'/>
|
||||
<label for='description'/>
|
||||
<field name='description'/>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
@@ -494,6 +524,13 @@
|
||||
<field name="model">lunch.alert</field>
|
||||
<field name="arch" type="xml">
|
||||
<form>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
<button name="toggle_active" type="object"
|
||||
class="oe_stat_button" icon="fa-archive">
|
||||
<field name="active" widget="boolean_button"
|
||||
options='{"terminology": "archive"}'/>
|
||||
</button>
|
||||
</div>
|
||||
<group>
|
||||
<group string="Schedule Date">
|
||||
<field name="alert_type"/>
|
||||
|
||||
Reference in New Issue
Block a user