Skip to content

Commit

Permalink
temp rebasing PR 427 (371c727)
Browse files Browse the repository at this point in the history
  • Loading branch information
roboadhoc committed Jan 29, 2024
2 parents 841a26a + 371c727 commit 5619825
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 22 deletions.
1 change: 1 addition & 0 deletions stock_orderpoint_manual_update/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# directory
##############################################################################
from . import models
from . import wizard
2 changes: 2 additions & 0 deletions stock_orderpoint_manual_update/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
'purchase_stock',
],
'data': [
'wizard/stock_warehouse_orderpoint_wizard_views.xml',
'security/ir.model.access.csv',
'views/stock_warehouse_orderpoint_views.xml',
],
'demo': [
Expand Down
21 changes: 21 additions & 0 deletions stock_orderpoint_manual_update/models/stock_orderpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ def _get_orderpoint_action(self):
self.update_qty_forecast()
return action

def _get_orderpoint_products(self):
domain = [('type', '=', 'product'), ('stock_move_ids', '!=', False)]

# Filter by suppliers
suppliers_ids = self._context.get('suppliers')
suppliers = self.env['product.supplierinfo'].browse(suppliers_ids)
if suppliers:
domain += ['|', ('product_tmpl_id', 'in', suppliers.product_tmpl_id.ids), ('id', 'in', suppliers.product_id.ids)]

# Filter by product categories
category_ids = self._context.get('categories')
if category_ids:
domain += [('categ_id', 'in', category_ids)]

# Filter by products
product_ids = self._context.get('products')
if product_ids:
domain += [('id', 'in', product_ids)]

return self.env['product.product'].search(domain)

def update_qty_forecast(self):
orderpoints = self.with_context(active_test=False).search([])
for rec in orderpoints:
Expand Down
2 changes: 2 additions & 0 deletions stock_orderpoint_manual_update/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_stock_warehouse_orderpoint_wizard,access_stock_warehouse_orderpoint_wizard,stock_orderpoint_manual_update.model_stock_warehouse_orderpoint_wizard,base.group_user,1,1,1,1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ patch(StockOrderpointListController.prototype, "order patch", {

patch(StockOrderpointListController.prototype, "recompute patch", {
async onClickRecomputeOrderpoint() {
return this.actionService.doAction('stock.action_replenishment');
return this.actionService.doAction('stock_orderpoint_manual_update.action_stock_warehouse_orderpoint_wizard');
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,4 @@
</field>
</record>

<record id="cron_create_orderpoints" model="ir.cron">
<field name="name">Replenishment: create new lines</field>
<field name="model_id" ref="stock.model_stock_warehouse_orderpoint"/>
<field name="state">code</field>
<field name="code">model._get_orderpoint_action()</field>
<field name="active" eval="True"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
</record>

<record id="stock.action_orderpoint_replenish" model="ir.actions.act_window">
<field name="context">{'search_default_filter_to_reorder': 1, 'search_default_filter_not_snoozed': 1}</field>
</record>

<menuitem
id="stock.menu_reordering_rules_replenish"
action="stock.action_orderpoint_replenish"
name="Replenishment" parent="stock.menu_stock_warehouse_mgmt" sequence="5"
groups="stock.group_stock_manager"/>

</odoo>
4 changes: 4 additions & 0 deletions stock_orderpoint_manual_update/wizard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- encoding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from . import stock_warehouse_orderpoint_wizard
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from odoo import fields, models, _


class StockWarehouseOrderpointWizard(models.TransientModel):
_name = 'stock.warehouse.orderpoint.wizard'
_description = 'Stock Warehouse Orderpoint Wizard'

company_id = fields.Many2one('res.company', 'Company', default=lambda self: self.env.company)
partner_ids = fields.Many2many('res.partner', string='Vendor', check_company=True)
category_ids = fields.Many2many('product.category', string='Product Category')
product_ids = fields.Many2many('product.product', string='Product')

def action_confirm(self):
ctx = self._context.copy()
suppliers = self.env['product.supplierinfo'].search([('partner_id', 'in', self.partner_ids.ids)])
ctx.update({
'suppliers': suppliers.ids,
'categories': self.category_ids.ids,
'products': self.product_ids.ids,
})
self = self.with_context(ctx)
action = self.env['stock.warehouse.orderpoint']._get_orderpoint_action()
return action

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="stock_warehouse_orderpoint_wizard">
<field name="name">stock.warehouse.orderpoint.wizard</field>
<field name="model">stock.warehouse.orderpoint.wizard</field>
<field name="arch" type="xml">
<form string="Replenishment Filter Wizard">
<div colspan="2" class="alert alert-info" role="status" attrs="{'invisible': [('partner_ids','=', []), ('category_ids','=', []), ('product_ids','=', [])]}">
<p><i class="fa fa-info-circle"/>This action will create replenishment lines for products that matches this criteria.</p>
</div>
<group>
<group col="2">
<field name="company_id" invisible="1"/>
<field name="partner_ids" widget="many2many_tags" context="{'res_partner_search_mode': 'supplier'}"></field>
<field name="product_ids" widget="many2many_tags"/>
</group>
<group col="2">
<field name="category_ids" widget="many2many_tags"/>
</group>
</group>
<footer>
<button string="Send" name="action_confirm" type="object" class="btn-primary" data-hotkey="q"/>
<button string="Cancel" class="btn-secondary" special="cancel" data-hotkey="z"/>
</footer>
</form>
</field>
</record>
</data>

<record id="action_stock_warehouse_orderpoint_wizard" model="ir.actions.act_window">
<field name="name">Manual Create Replenishments</field>
<field name="res_model">stock.warehouse.orderpoint.wizard</field>
<field name="view_ids"
eval="[(5, 0, 0),
(0, 0, {'view_mode': 'form', 'view_id': ref('stock_warehouse_orderpoint_wizard')})]" />
<field name="target">new</field>
</record>

<record id="cron_create_orderpoints" model="ir.cron">
<field name="name">Replenishment: create new lines</field>
<field name="model_id" ref="stock.model_stock_warehouse_orderpoint"/>
<field name="state">code</field>
<field name="code">model._get_orderpoint_action()</field>
<field name="active" eval="True"/>
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
</record>

<record id="stock.action_orderpoint_replenish" model="ir.actions.act_window">
<field name="context">{'search_default_filter_to_reorder': 1, 'search_default_filter_not_snoozed': 1}</field>
</record>

<menuitem
id="stock.menu_reordering_rules_replenish"
action="stock.action_orderpoint_replenish"
name="Replenishment" parent="stock.menu_stock_warehouse_mgmt" sequence="5"
groups="stock.group_stock_manager"/>

</odoo>

0 comments on commit 5619825

Please sign in to comment.