• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OCA / stock-logistics-workflow / 258

pending completion
258

Pull #64

travis-ci

moylop260
Merge pull request #5 from vauxoo-dev/8.0-fix-warn-dev-moylop260

[REF] product_unique_serial: Fix warn fast_suite deprecated
Pull Request #64: [ADD] product unique serial modules to preserve consistency

118 of 118 new or added lines in 5 files covered. (100.0%)

467 of 776 relevant lines covered (60.18%)

1.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

29.17
/product_unique_serial/wizard/stock_transfer_details.py
1
# -*- coding: utf-8 -*-
2

3
from lxml import etree
2✔
4

5
from openerp import models, api
2✔
6

7

8
# TODO: Looking for how append domain string
9
def domain_str_append(old_domain_str, subdomain_str):
2✔
10
    return old_domain_str.replace(
×
11
        "]",
12
        ", " + subdomain_str + "]")
13

14

15
class StockTransferDetails(models.TransientModel):
2✔
16
    _inherit = 'stock.transfer_details'
2✔
17

18
    @api.model
2✔
19
    def fields_view_get(self, view_id=None, view_type='form',
2✔
20
                        toolbar=False, submenu=False):
21
        """
22
        Allow create serial only with incoming picking
23
        Set option "no_create = True"
24
        when picking type is different to incoming.
25
        """
26
        res = super(StockTransferDetails, self).fields_view_get(
×
27
            view_id=view_id, view_type=view_type,
28
            toolbar=toolbar, submenu=submenu)
29
        context = self._context
×
30
        if 'item_ids' in res['fields']:
×
31
            arch = res['fields']['item_ids'][
×
32
                'views']['tree']['arch']
33
            doc = etree.XML(arch)
×
34
            if context.get('active_model') == 'stock.picking' \
×
35
               and context.get('active_id'):
36
                picking = self.env['stock.picking'].\
×
37
                    browse(context['active_id'])
38
                for node in doc.xpath("//field[@name='lot_id']"):
×
39
                    if picking.picking_type_id.code != 'incoming':
×
40
                        node.set('options', "{'no_create': True}")
×
41
                        # Don't show unused serial.
42
                        # allow to select a serial with moves.
43
                        # TODO: Disable this option when
44
                        #       fields.function last_location_id
45
                        #       was fix it
46
                        sub_domain = "('quant_ids', '!=', [])"
×
47
                        # Set domain to show only serial number
48
                        # that exists in source location
49
                        # TODO: Enable when fields.function
50
                        #       last_location_id was fix it
51
                        # sub_domain = "('last_location_id', '=', " + \
52
                        #     "sourceloc_id)"
53
                    else:
54
                        # Don't show old serial number
55
                        # just allow to create new one or
56
                        # allow to select a serial without moves
57
                        sub_domain = "('quant_ids', '=', [])"
×
58
                    new_domain = domain_str_append(
×
59
                        node.get('domain'), sub_domain)
60
                    node.set('domain', new_domain)
×
61
                res['fields']['item_ids']['views'][
×
62
                    'tree']['arch'] = etree.tostring(doc)
63
        return res
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc