Adding fields to your Doctype in LENS allows you to add various fields to capture the specific data you need.
Here’s a simplified guide to doing this:
Steps:
-
Access the DocType List:
- Start by navigating to your custom Doctype in LENS.
- Open the DocType you created previously.
-
Add Fields:
- Item Name (Data): A simple text field where you can enter the name of an item, such as 'Laptop' or 'Office Chair.'
- Description (Text): A larger text field for a detailed description of the item, including features or specifications.
- Quantity (Int): An integer field to store the quantity of items available or needed.
- Price (Float): A field to store the price of the item, allowing for decimal values like '19.99.'
- Manufacture Date (Date): A date field to record when the item was manufactured.
- In Stock (Check): A checkbox to indicate if the item is currently in stock.
- Category (Select): A dropdown menu with predefined options like 'Electronics,' 'Furniture,' and 'Apparel' for easy categorization.
- Supplier (Link): A link to another Doctype, such as 'Supplier,' to identify who provides the item.
-
Save and Test:
- After adding the fields, save your changes to the Doctype.
- To test, create a few records by entering data into each field. This helps you verify that the fields are working as expected and that the data is stored correctly in the database.
Docstatus
Docstatus is a field in LENS that indicates the status of a document (record) within a DocType. It helps in managing the workflow of documents by categorizing them based on their state. The common values for docstatus
are:
- 0: Draft – The document is still being created and not finalized.
- 1: Submitted – The document has been submitted and is now part of the workflow.
- 2: Cancelled – The document has been cancelled and is no longer active.
Example of Docstatus
Draft (docstatus = 0
):
- The sales order is being created but not yet finalized.
sales_order = frappe.get_doc({
'doctype': 'Sales Order',
'customer': 'Customer A',
'items': [{'item_code': 'Item 1', 'qty': 2}]
})
##### sales_order.insert() docstatus is 0
Submitted (docstatus = 1
):
- Once you review and finalize the order, you submit it.
##### sales_order.submit() docstatus changes to 1
Cancelled (docstatus = 2
):
- If you need to cancel the order after submission, you can do so.
##### sales_order.cancel() docstatus changes to 2
Naming in DocType
In LENS, naming refers to how a document (or record) is identified within a DocType.
1. Naming Series
- Definition: A naming series allows users to define a custom sequence or pattern for naming documents. It can include prefixes, suffixes, and numeric sequences.
- Usage: Useful for maintaining order and consistency in naming documents.
2. Naming Rule
- Definition: Naming rules dictate how names are generated for new documents. This includes specifying which fields to use and the format for constructing the name.
- Implementation: Rules can include static text, dynamic fields, and date or counter values.
3. Auto Name
- Definition: Auto naming automatically generates a unique name for a document based on a predefined format when the document is created.
- Formats:
- Field-based: Using specific fields to create the name (e.g.,
Customer-{customer_id}
).
- Counter: Incremental numbering (e.g.,
Sales Invoice-0001
).
4. Name Case
- Definition: Name case refers to the formatting of the document name, which can be specified as upper case, lower case, or title case. This ensures uniformity and readability.
- Example:
- Title Case: 'Sales Order'
- Upper Case: 'SALES ORDER'