Filter stock moves and return order's
I want to filter in Tree view SO's that have stock.pickings and some stock.moves in those pickings are in a state "assigned".
I created selection field that is computed and fnct_search method but it's not even triggered. what is wrong in my code? and logic.
picking_id_states = fields.Selection([
('draft', 'Draft'), ('cancel', 'Cancelled'),
('waiting', 'Waiting Another Operation'),
('confirmed', 'Waiting Availability'),
('partially_available', 'Partially Available'),
('assigned', 'Available'), ('done', 'Done')], compute='compute_picking_state', string='Picking State',
fnct_search='_move_search', store=False, copy=False, index=True, readonly=True)
def _move_search(self, operator, value):
print "test"
for so in self:
moves = so.picking_ids.mapped('move_lines')
filtered_moves = moves.filtered(lambda l: l.state == 'assigned')
if filtered_moves:
so_ids = filtered_moves.mapped('picking_id.sale_id')
return [('id', 'in', so_ids)]
@api.depends('order_line.move_ids', 'order_line.move_ids.state')
def compute_picking_state(self):
for order in self:
for picking in order.picking_ids:
order.picking_id_state = picking.state
XML code is
<record id="view_sale_order_search_picking_state" model="ir.ui.view">
<field name="name">Config Hetlta picking state</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_sales_order_filter" />
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="picking_id_state"/>
<field name="note"/>
</field>
<filter name="sales" position="after">
<filter string="Picking state" name="picking_id_states" />
</filter>
</field>
</record>
odoo odoo-8 odoo-9
add a comment |
I want to filter in Tree view SO's that have stock.pickings and some stock.moves in those pickings are in a state "assigned".
I created selection field that is computed and fnct_search method but it's not even triggered. what is wrong in my code? and logic.
picking_id_states = fields.Selection([
('draft', 'Draft'), ('cancel', 'Cancelled'),
('waiting', 'Waiting Another Operation'),
('confirmed', 'Waiting Availability'),
('partially_available', 'Partially Available'),
('assigned', 'Available'), ('done', 'Done')], compute='compute_picking_state', string='Picking State',
fnct_search='_move_search', store=False, copy=False, index=True, readonly=True)
def _move_search(self, operator, value):
print "test"
for so in self:
moves = so.picking_ids.mapped('move_lines')
filtered_moves = moves.filtered(lambda l: l.state == 'assigned')
if filtered_moves:
so_ids = filtered_moves.mapped('picking_id.sale_id')
return [('id', 'in', so_ids)]
@api.depends('order_line.move_ids', 'order_line.move_ids.state')
def compute_picking_state(self):
for order in self:
for picking in order.picking_ids:
order.picking_id_state = picking.state
XML code is
<record id="view_sale_order_search_picking_state" model="ir.ui.view">
<field name="name">Config Hetlta picking state</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_sales_order_filter" />
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="picking_id_state"/>
<field name="note"/>
</field>
<filter name="sales" position="after">
<filter string="Picking state" name="picking_id_states" />
</filter>
</field>
</record>
odoo odoo-8 odoo-9
add a comment |
I want to filter in Tree view SO's that have stock.pickings and some stock.moves in those pickings are in a state "assigned".
I created selection field that is computed and fnct_search method but it's not even triggered. what is wrong in my code? and logic.
picking_id_states = fields.Selection([
('draft', 'Draft'), ('cancel', 'Cancelled'),
('waiting', 'Waiting Another Operation'),
('confirmed', 'Waiting Availability'),
('partially_available', 'Partially Available'),
('assigned', 'Available'), ('done', 'Done')], compute='compute_picking_state', string='Picking State',
fnct_search='_move_search', store=False, copy=False, index=True, readonly=True)
def _move_search(self, operator, value):
print "test"
for so in self:
moves = so.picking_ids.mapped('move_lines')
filtered_moves = moves.filtered(lambda l: l.state == 'assigned')
if filtered_moves:
so_ids = filtered_moves.mapped('picking_id.sale_id')
return [('id', 'in', so_ids)]
@api.depends('order_line.move_ids', 'order_line.move_ids.state')
def compute_picking_state(self):
for order in self:
for picking in order.picking_ids:
order.picking_id_state = picking.state
XML code is
<record id="view_sale_order_search_picking_state" model="ir.ui.view">
<field name="name">Config Hetlta picking state</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_sales_order_filter" />
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="picking_id_state"/>
<field name="note"/>
</field>
<filter name="sales" position="after">
<filter string="Picking state" name="picking_id_states" />
</filter>
</field>
</record>
odoo odoo-8 odoo-9
I want to filter in Tree view SO's that have stock.pickings and some stock.moves in those pickings are in a state "assigned".
I created selection field that is computed and fnct_search method but it's not even triggered. what is wrong in my code? and logic.
picking_id_states = fields.Selection([
('draft', 'Draft'), ('cancel', 'Cancelled'),
('waiting', 'Waiting Another Operation'),
('confirmed', 'Waiting Availability'),
('partially_available', 'Partially Available'),
('assigned', 'Available'), ('done', 'Done')], compute='compute_picking_state', string='Picking State',
fnct_search='_move_search', store=False, copy=False, index=True, readonly=True)
def _move_search(self, operator, value):
print "test"
for so in self:
moves = so.picking_ids.mapped('move_lines')
filtered_moves = moves.filtered(lambda l: l.state == 'assigned')
if filtered_moves:
so_ids = filtered_moves.mapped('picking_id.sale_id')
return [('id', 'in', so_ids)]
@api.depends('order_line.move_ids', 'order_line.move_ids.state')
def compute_picking_state(self):
for order in self:
for picking in order.picking_ids:
order.picking_id_state = picking.state
XML code is
<record id="view_sale_order_search_picking_state" model="ir.ui.view">
<field name="name">Config Hetlta picking state</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_sales_order_filter" />
<field name="arch" type="xml">
<field name="user_id" position="after">
<field name="picking_id_state"/>
<field name="note"/>
</field>
<filter name="sales" position="after">
<filter string="Picking state" name="picking_id_states" />
</filter>
</field>
</record>
odoo odoo-8 odoo-9
odoo odoo-8 odoo-9
asked Nov 15 '18 at 16:20
Chaban33Chaban33
354215
354215
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The self
in computed fields search methods is always empty, there are no recordsets. You have to take the operator and value (search term) and create your own "indirect" search for order ids.
But a maybe easier way is to just store the computed field. Odoo can only search by database persistent fields, which would be given when stored.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323727%2ffilter-stock-moves-and-return-orders%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The self
in computed fields search methods is always empty, there are no recordsets. You have to take the operator and value (search term) and create your own "indirect" search for order ids.
But a maybe easier way is to just store the computed field. Odoo can only search by database persistent fields, which would be given when stored.
add a comment |
The self
in computed fields search methods is always empty, there are no recordsets. You have to take the operator and value (search term) and create your own "indirect" search for order ids.
But a maybe easier way is to just store the computed field. Odoo can only search by database persistent fields, which would be given when stored.
add a comment |
The self
in computed fields search methods is always empty, there are no recordsets. You have to take the operator and value (search term) and create your own "indirect" search for order ids.
But a maybe easier way is to just store the computed field. Odoo can only search by database persistent fields, which would be given when stored.
The self
in computed fields search methods is always empty, there are no recordsets. You have to take the operator and value (search term) and create your own "indirect" search for order ids.
But a maybe easier way is to just store the computed field. Odoo can only search by database persistent fields, which would be given when stored.
answered Nov 16 '18 at 8:13
CZoellnerCZoellner
7,28331630
7,28331630
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323727%2ffilter-stock-moves-and-return-orders%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown