Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
6089 Widoki
<record id="act_product_pos_sale" model="ir.actions.act_window">
            <field name="name">POS Product Sale1</field>
            <field name="res_model">product.product</field>
            <field name="view_id" ref="product.product_product_tree_view"/>
        </record>

        <record model="ir.ui.view" id="product_form_pos_sale_button">
            <field name="name">product.product.sale.pos.order</field>
            <field name="model">product.product</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                <div name="button_box" position="inside">
                    <button class="oe_stat_button" name="action_view_pos_product"
                        type="object" icon="fa-usd">
                        <field string="POS" name="pos_product_order_total" widget="statinfo" />
                    </button>
                </div>
            </field>
        </record>


class ProductProduct(models.Model):
    _inherit = 'product.product'

 @api.multi
    def action_view_pos_product(self):
        OrderLine = self.env['pos.order.line']
        action = self.env.ref('sale.act_product_pos_sale')
        # action['domain'] = [('product_id', 'in', products.ids)]
        # action['context'] = {'': ,}
        return action


In Product form view there is Button Sale. When you activate it shows tree view with all sale orders for this product. My goal is to make the same button but it has to show all pos orders that was made with this product.

i tried something like this but i know it's total garbage. If someone could explain to me how it works i will be more then grateful

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

you could do something like this:


        <record model="ir.ui.view" id="product_form_pos_sale_button">
            <field name="name">product.product.sale.pos.order</field>
            <field name="model">product.product</field>
            <field name="inherit_id" ref="product.product_normal_form_view"/>
            <field name="arch" type="xml">
                <div name="button_box" position="inside">
                    <button class="oe_stat_button" name="open_pos_orders" icon="fa-book" type="object">
                 </div>
            </field>
     </record>
@api.multi
def open_pos_orders(self):
self.ensure_one()
pos_orders = self.env['pos.order.line'].search([('product_id', '=', self.id)]).mapped('order_id')

return {
'type': 'ir.actions.act_window',
'name': _('POS orders'),
'res_model': 'pos.order',
'view_mode': 'tree,form',
'domain': [('id', 'in', pos_orders.ids)],
}

            
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
mar 23
2464
0
maj 19
3147
1
sie 25
786
1
lip 25
1044
3
lip 25
3501